Hi,
I need to be able to grant exclusive access to a persistant object in our object model to a single user. I intend to use session.lock(theObj, LockMode.UPGRADE_NOWAIT), but I'm a bit confused as to how this works. Could someone answer the following questions for me?
1) Does calling session.lock() automatically re-SELECT the specified object with the "FOR UPDATE NOWAIT" clause?
1a) If not, should I call theObj.refresh() following the session.lock() call to ensure valid data?
2) Will a HibernateException be thrown by session.lock() if another session currently holds a lock on this object (row)?
3) Does committing my transaction release the lock, or do I need to explicitly call session.lock() again with a lower isolation level?
FWIW, I have read many threads regarding letting the DB take care of locking for me, and I believe that I have a valid case for explicit locking. I'm happy to share if need be.
--------------------------------------------------------------------------------
|