Hi All-
I want to use Hibernate�s optimistic locking but I want to be able to recover from a lock exception within the same transaction � is this possible?
The scenario:
We have a hierarchy of records that may be updated by multiple users during periods of high activity. These are total records and when a user is trying to update a stale record, I want to:
1)catch the optimistic lock exception
2)retrieve my original data (in user cache) and calculate deltas
3)find the latest record (which caused the optimistic lock exception � I do a flush after every save so it�s current)
4)add the deltas to the new record
5)save the updated record
The problem I�m having is at step 3. I can�t find my record because the transaction no longer exists and my session is dead. I�ve read that Hibernate errors like this are non-recoverable. Can I do this? Or do I have to implement my own user version checking to check for stale data (i.e. finding the record before I save) in order to recover programmatically?
(We�re using
JBoss 4 , Seam + Hibernate)
thanks
Max