The
Hibernate manual states that Sessions should be discarded when an exception is thrown:
Quote:
If the Session throws an exception (including any SQLException), you should immediately rollback the transaction, call Session.close() and discard the Session instance. Certain methods of Session will not leave the session in a consistent state.
Does this apply when an attempt to acquire a lock fails?
Code:
// re-attach a detached object
aSession.lock(anObject, LockMode.NONE);
I'd like to continue using Sessions after lock acquisition failures under a variety of circumstances. The most mundane example is using lock() to do a version check. Same for attempting to acquire a pessimistic lock with NOWAIT.