當前位置: 首頁>>代碼示例>>Java>>正文


Java LockMode.greaterThan方法代碼示例

本文整理匯總了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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:38,代碼來源:AbstractTransactSQLDialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:Cache71Dialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:TimesTenDialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:PointbaseDialect.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:AbstractHANADialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:RDMSOS2200Dialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:MckoiDialect.java

示例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 );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:Dialect.java

示例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 );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:FrontBaseDialect.java

示例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 );
			}
		}

	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:68,代碼來源:AbstractLockUpgradeEventListener.java


注:本文中的org.hibernate.LockMode.greaterThan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。