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


Java CollectionPersister.isAffectedByEnabledFilters方法代码示例

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


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

示例1: initializeCollectionFromCache

import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
/**
 * Try to initialize a collection from the cache
 *
 * @param id The id of the collection of initialize
 * @param persister The collection persister
 * @param collection The collection to initialize
 * @param source The originating session
 *
 * @return true if we were able to initialize the collection from the cache;
 *         false otherwise.
 */
private boolean initializeCollectionFromCache(
		Serializable id,
		CollectionPersister persister,
		PersistentCollection collection,
		SessionImplementor source) {

	if ( !source.getLoadQueryInfluencers().getEnabledFilters().isEmpty()
			&& persister.isAffectedByEnabledFilters( source ) ) {
		LOG.trace( "Disregarding cached version (if any) of collection due to enabled filters" );
		return false;
	}

	final boolean useCache = persister.hasCache() && source.getCacheMode().isGetEnabled();

	if ( !useCache ) {
		return false;
	}

	final SessionFactoryImplementor factory = source.getFactory();
	final CacheKey ck = source.generateCacheKey( id, persister.getKeyType(), persister.getRole() );
	final Object ce = CacheHelper.fromSharedCache( source, ck, persister.getCacheAccessStrategy() );

	if ( factory.getStatistics().isStatisticsEnabled() ) {
		if ( ce == null ) {
			factory.getStatisticsImplementor()
					.secondLevelCacheMiss( persister.getCacheAccessStrategy().getRegion().getName() );
		}
		else {
			factory.getStatisticsImplementor()
					.secondLevelCacheHit( persister.getCacheAccessStrategy().getRegion().getName() );
		}
	}

	if ( ce == null ) {
		return false;
	}

	CollectionCacheEntry cacheEntry = (CollectionCacheEntry) persister.getCacheEntryStructure().destructure(
			ce,
			factory
	);

	final PersistenceContext persistenceContext = source.getPersistenceContext();
	cacheEntry.assemble( collection, persister, persistenceContext.getCollectionOwner( id, persister ) );
	persistenceContext.getCollectionEntry( collection ).postInitialize( collection );
	// addInitializedCollection(collection, persister, id);
	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:60,代码来源:DefaultInitializeCollectionEventListener.java

示例2: execute

import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
@Override
public void execute() throws HibernateException {
	final Serializable id = getKey();
	final SessionImplementor session = getSession();
	final CollectionPersister persister = getPersister();
	final PersistentCollection collection = getCollection();
	final boolean affectedByFilters = persister.isAffectedByEnabledFilters( session );

	preUpdate();

	if ( !collection.wasInitialized() ) {
		if ( !collection.hasQueuedOperations() ) {
			throw new AssertionFailure( "no queued adds" );
		}
		//do nothing - we only need to notify the cache... 
	}
	else if ( !affectedByFilters && collection.empty() ) {
		if ( !emptySnapshot ) {
			persister.remove( id, session );
		}
	}
	else if ( collection.needsRecreate( persister ) ) {
		if ( affectedByFilters ) {
			throw new HibernateException(
					"cannot recreate collection while filter is enabled: " +
							MessageHelper.collectionInfoString( persister, collection, id, session )
			);
		}
		if ( !emptySnapshot ) {
			persister.remove( id, session );
		}
		persister.recreate( collection, id, session );
	}
	else {
		persister.deleteRows( collection, id, session );
		persister.updateRows( collection, id, session );
		persister.insertRows( collection, id, session );
	}

	getSession().getPersistenceContext().getCollectionEntry( collection ).afterAction( collection );
	evict();
	postUpdate();

	if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
		getSession().getFactory().getStatisticsImplementor().updateCollection( getPersister().getRole() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:CollectionUpdateAction.java


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