Be careful when using session.lock(object, LockMode.UPGRADE);
The best practice is to check the object whether if it's already locked with
UPGRADE mode.
public void selectForUpdate(Object object) {
if (getSession().getCurrentLockMode(object) !=
LockMode.UPGRADE) {
getSession().refresh(object, LockMode.UPGRADE);
}
}
Because if an object is already locked, locking it again will release the
previous locking.
Hibernate - The Concurrency Issue
Subscribe to:
Post Comments (Atom)
0 comments: (+add yours?)
Post a Comment