本文整理汇总了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;
}
示例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() );
}
}