本文整理汇总了Java中org.hibernate.LockMode.greaterThan方法的典型用法代码示例。如果您正苦于以下问题:Java LockMode.greaterThan方法的具体用法?Java LockMode.greaterThan怎么用?Java LockMode.greaterThan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.LockMode
的用法示例。
在下文中一共展示了LockMode.greaterThan方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyLocksToSql
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
// TODO: merge additional lockoptions support in Dialect.applyLocksToSql
final Iterator itr = aliasedLockOptions.getAliasLockIterator();
final StringBuilder buffer = new StringBuilder( sql );
int correction = 0;
while ( itr.hasNext() ) {
final Map.Entry entry = (Map.Entry) itr.next();
final LockMode lockMode = (LockMode) entry.getValue();
if ( lockMode.greaterThan( LockMode.READ ) ) {
final String alias = (String) entry.getKey();
int start = -1;
int end = -1;
if ( sql.endsWith( " " + alias ) ) {
start = ( sql.length() - alias.length() ) + correction;
end = start + alias.length();
}
else {
int position = sql.indexOf( " " + alias + " " );
if ( position <= -1 ) {
position = sql.indexOf( " " + alias + "," );
}
if ( position > -1 ) {
start = position + correction + 1;
end = start + alias.length();
}
}
if ( start > -1 ) {
final String lockHint = appendLockHint( lockMode, alias );
buffer.replace( start, end, lockHint );
correction += ( lockHint.length() - alias.length() );
}
}
}
return buffer.toString();
}
示例2: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
// Set your transaction mode to READ_COMMITTED before using
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例3: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC ) {
return new OptimisticLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例4: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例5: getForUpdateString
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public String getForUpdateString(final String aliases, final LockOptions lockOptions) {
LockMode lockMode = lockOptions.getLockMode();
final Iterator<Map.Entry<String, LockMode>> itr = lockOptions.getAliasLockIterator();
while ( itr.hasNext() ) {
// seek the highest lock mode
final Map.Entry<String, LockMode> entry = itr.next();
final LockMode lm = entry.getValue();
if ( lm.greaterThan( lockMode ) ) {
lockMode = lm;
}
}
// not sure why this is sometimes empty
if ( aliases == null || "".equals( aliases ) ) {
return getForUpdateString( lockMode );
}
return getForUpdateString( lockMode ) + " of " + aliases;
}
示例6: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC ) {
return new OptimisticLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例7: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例8: getForUpdateString
import org.hibernate.LockMode; //导入方法依赖的package包/类
/**
* Get the <tt>FOR UPDATE OF column_list</tt> fragment appropriate for this
* dialect given the aliases of the columns to be write locked.
*
* @param aliases The columns to be write locked.
* @param lockOptions the lock options to apply
* @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string.
*/
@SuppressWarnings({"unchecked", "UnusedParameters"})
public String getForUpdateString(String aliases, LockOptions lockOptions) {
LockMode lockMode = lockOptions.getLockMode();
final Iterator<Map.Entry<String, LockMode>> itr = lockOptions.getAliasLockIterator();
while ( itr.hasNext() ) {
// seek the highest lock mode
final Map.Entry<String, LockMode>entry = itr.next();
final LockMode lm = entry.getValue();
if ( lm.greaterThan( lockMode ) ) {
lockMode = lm;
}
}
lockOptions.setLockMode( lockMode );
return getForUpdateString( lockOptions );
}
示例9: getLockingStrategy
import org.hibernate.LockMode; //导入方法依赖的package包/类
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例10: upgradeLock
import org.hibernate.LockMode; //导入方法依赖的package包/类
/**
* Performs a pessimistic lock upgrade on a given entity, if needed.
*
* @param object The entity for which to upgrade the lock.
* @param entry The entity's EntityEntry instance.
* @param lockOptions contains the requested lock mode.
* @param source The session which is the source of the event being processed.
*/
protected void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource source) {
LockMode requestedLockMode = lockOptions.getLockMode();
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
// The user requested a "greater" (i.e. more restrictive) form of
// pessimistic lock
if ( entry.getStatus() != Status.MANAGED ) {
throw new ObjectDeletedException(
"attempted to lock a deleted instance",
entry.getId(),
entry.getPersister().getEntityName()
);
}
final EntityPersister persister = entry.getPersister();
if ( log.isTraceEnabled() ) {
log.tracev(
"Locking {0} in mode: {1}",
MessageHelper.infoString( persister, entry.getId(), source.getFactory() ),
requestedLockMode
);
}
final SoftLock lock;
final CacheKey ck;
if ( persister.hasCache() ) {
ck = source.generateCacheKey( entry.getId(), persister.getIdentifierType(), persister.getRootEntityName() );
lock = persister.getCacheAccessStrategy().lockItem( ck, entry.getVersion() );
}
else {
ck = null;
lock = null;
}
try {
if ( persister.isVersioned() && requestedLockMode == LockMode.FORCE ) {
// todo : should we check the current isolation mode explicitly?
Object nextVersion = persister.forceVersionIncrement(
entry.getId(), entry.getVersion(), source
);
entry.forceLocked( object, nextVersion );
}
else {
persister.lock( entry.getId(), entry.getVersion(), object, lockOptions, source );
}
entry.setLockMode(requestedLockMode);
}
finally {
// the database now holds a lock + the object is flushed from the cache,
// so release the soft lock
if ( persister.hasCache() ) {
persister.getCacheAccessStrategy().unlockItem( ck, lock );
}
}
}
}