File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate Cache problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Hibernate Cache problem" Watch "Hibernate Cache problem" New topic
Author

Hibernate Cache problem

D.Praveen Nair
Greenhorn

Joined: Jul 28, 2006
Posts: 2
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

Joined: Feb 05, 2001
Posts: 16622

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
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
 
 
subject: Hibernate Cache problem
 
Threads others viewed
Record Locking in multi-user
few questions about design struts application
sping+hibernate got NullException
How to know the type of request coming from the form
how to scroll data to view other records
IntelliJ Java IDE