Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Cache problem

 
D.Praveen Nair
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Hibernate 3.0 in my application. I have a list of records retrieved from the oracle db using hibernate and shown in my page. Now when i delete a record and try to add that same record again, it does not get added. But if i go to some other page and come back to this page and then try to add the same record, it allows me to add the record. I have been stuck on this for 3 days now. Please help me out.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well to evict objects out of cache there are two ways and each for which cache level the object happens to be in.

session.evict and sessionFactory.evict. For the first and second level cache's respectively. Or flush or close the session and reopen a new one, for the first level cache.

Mark
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by "same record" ? do you assign the PK yourself and use the same PK as the deleted object ? if your not generating PKs by "assigned" then its hibernate controlling the PK and then you can not add the "same record" again.

i dont see how this could happen and therefore i just ask a lots of questions that come to mind. perhaps one of them is leading you in the right direction...
what cache do you mean ? the hibernate cache ? which 1st (Session) or 2nd (do you have enabled it ?) or the cache from browser (form field values, page) or web server ? do you commit the TX after deleting ? where/how are the transaction s manged ? how do you insert/delete ? can we see some code ?


ufff.... have a good night :-)


pascal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic