public void lock ( boolean shouldLock ) { String lastAlias = getLastAlias ( ) ; if ( shouldLock ) { if ( lastAlias != null ) { criteria . setLockMode ( lastAlias , LockMode . PESSIMISTIC_WRITE ) ; } else { criteria . setLockMode ( LockMode . PESSIMISTIC_WRITE ) ; } } else { if ( lastAlias != null ) { criteria . setLockMode ( lastAlias , LockMode . NONE ) ; } else { criteria . setLockMode ( LockMode . NONE ) ; } } }
Whether a pessimistic lock should be obtained .