Hello all,
I haven't been able to find the answer to this question anywhere and am hoping you can help.
Let's say my application selects a bunch of objects from the database as part of a session. Now, let's say I iterate over the items in that collection and try to update each one. But there's other applications running that are also trying to update the same objects in the database. Eventually, as my application runs, while it is modifying one of the objects and performing commits, I get a StaleObjectException (as I would expect since I have other applications trying to do the same thing that I am doing). How can I "remove" that stale object from my session? In other words, when I get the StaleObjectException, I want my application to "give up" on trying to modify that object - and just "move on" to the next object in the collection. In the current version of my application, I "give up" on the object and attempt to update/commit the next object in the collection - but I keep getting the StaleObjectException from the previous object.
I thought perhaps the session.evict() method might be the answer but Hibernate In Action implies that it's not. I don't see a session.remove method...
Any thoughts?
Thanks!
-john
|