当前位置: 首页>>代码示例>>Java>>正文


Java LockMode.lessThan方法代码示例

本文整理汇总了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 );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:EntityReferenceInitializerImpl.java

示例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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:UpdateLockingStrategy.java

示例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() + "]" );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:OptimisticLockingStrategy.java

示例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() + "]" );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:PessimisticForceIncrementLockingStrategy.java

示例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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PessimisticWriteUpdateLockingStrategy.java

示例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() + "]" );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:OptimisticForceIncrementLockingStrategy.java

示例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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:PessimisticReadUpdateLockingStrategy.java


注:本文中的org.hibernate.LockMode.lessThan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。