本文整理匯總了Java中org.hibernate.LockMode.lessThan方法的典型用法代碼示例。如果您正苦於以下問題:Java LockMode.lessThan方法的具體用法?Java LockMode.lessThan怎麽用?Java LockMode.lessThan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.LockMode
的用法示例。
在下文中一共展示了LockMode.lessThan方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkVersion
import org.hibernate.LockMode; //導入方法依賴的package包/類
private void checkVersion(
ResultSet resultSet,
ResultSetProcessingContext context,
EntityKey entityKey,
Object existing) {
final LockMode requestedLockMode = context.resolveLockMode( entityReference );
if ( requestedLockMode != LockMode.NONE ) {
final LockMode currentLockMode = context.getSession().getPersistenceContext().getEntry( existing ).getLockMode();
final boolean isVersionCheckNeeded = entityReference.getEntityPersister().isVersioned()
&& currentLockMode.lessThan( requestedLockMode );
// we don't need to worry about existing version being uninitialized because this block isn't called
// by a re-entrant load (re-entrant loads *always* have lock mode NONE)
if ( isVersionCheckNeeded ) {
//we only check the version when *upgrading* lock modes
checkVersion(
context.getSession(),
resultSet,
entityReference.getEntityPersister(),
entityReferenceAliases.getColumnAliases(),
entityKey,
existing
);
//we need to upgrade the lock mode to the mode requested
context.getSession().getPersistenceContext().getEntry( existing ).setLockMode( requestedLockMode );
}
}
}
示例2: UpdateLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct a locking strategy based on SQL UPDATE statements.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indictates the type of lock to be acquired. Note that
* read-locks are not valid for this strategy.
*/
public UpdateLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.UPGRADE ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for update statement" );
}
if ( !lockable.isVersioned() ) {
LOG.writeLocksNotSupported( lockable.getEntityName() );
this.sql = null;
}
else {
this.sql = generateLockString();
}
}
示例3: OptimisticLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct locking strategy.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired.
*/
public OptimisticLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.OPTIMISTIC ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" );
}
}
示例4: PessimisticForceIncrementLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct locking strategy.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired.
*/
public PessimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
// ForceIncrement can be used for PESSIMISTIC_READ, PESSIMISTIC_WRITE or PESSIMISTIC_FORCE_INCREMENT
if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" );
}
}
示例5: PessimisticWriteUpdateLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct a locking strategy based on SQL UPDATE statements.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. Note that read-locks are not valid for this strategy.
*/
public PessimisticWriteUpdateLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for update statement" );
}
if ( !lockable.isVersioned() ) {
LOG.writeLocksNotSupported( lockable.getEntityName() );
this.sql = null;
}
else {
this.sql = generateLockString();
}
}
示例6: OptimisticForceIncrementLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct locking strategy.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired.
*/
public OptimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.OPTIMISTIC_FORCE_INCREMENT ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" );
}
}
示例7: PessimisticReadUpdateLockingStrategy
import org.hibernate.LockMode; //導入方法依賴的package包/類
/**
* Construct a locking strategy based on SQL UPDATE statements.
*
* @param lockable The metadata for the entity to be locked.
* @param lockMode Indicates the type of lock to be acquired. Note that
* read-locks are not valid for this strategy.
*/
public PessimisticReadUpdateLockingStrategy(Lockable lockable, LockMode lockMode) {
this.lockable = lockable;
this.lockMode = lockMode;
if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) {
throw new HibernateException( "[" + lockMode + "] not valid for update statement" );
}
if ( !lockable.isVersioned() ) {
LOG.writeLocksNotSupported( lockable.getEntityName() );
this.sql = null;
}
else {
this.sql = generateLockString();
}
}