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


Java EventSource.generateCacheKey方法代码示例

本文整理汇总了Java中org.hibernate.event.spi.EventSource.generateCacheKey方法的典型用法代码示例。如果您正苦于以下问题:Java EventSource.generateCacheKey方法的具体用法?Java EventSource.generateCacheKey怎么用?Java EventSource.generateCacheKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.event.spi.EventSource的用法示例。


在下文中一共展示了EventSource.generateCacheKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evict

import org.hibernate.event.spi.EventSource; //导入方法依赖的package包/类
private void evict(Serializable id, CollectionPersister collectionPersister, EventSource session) {
	LOG.debug( "Evict CollectionRegion " + collectionPersister.getRole() + " for id " + id );
	CacheKey key = session.generateCacheKey( id, collectionPersister.getKeyType(), collectionPersister.getRole() );
	collectionPersister.getCacheAccessStrategy().evict( key );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:CollectionCacheInvalidator.java

示例2: upgradeLock

import org.hibernate.event.spi.EventSource; //导入方法依赖的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.event.spi.EventSource.generateCacheKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。