本文整理汇总了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();
}
}