| To enable the filter as well as L2 caching for Collections what if we change the following classes as indicated below? Will that work? Class CollectionLoadContext method: private void addCollectionToCache(final LoadingCollectionEntry lce, final CollectionPersister persister) { .. Just comment the following lines.. {{ if ( !session.getLoadQueryInfluencers().getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( session ) ) { // some filters affecting the collection are enabled on the session, so do not do the put into the cache. if ( debugEnabled ) { LOG.debug( "Refusing to add to cache due to enabled filters" ); } // todo : add the notion of enabled filters to the cache key to differentiate filtered collections from // non-filtered; // DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read // from // cache with enabled filters). // EARLY EXIT!!!!! return; }}} And inside DefaultInitializeCollectionEventListener method: private boolean initializeCollectionFromCache( final Serializable id, final CollectionPersister persister, final PersistentCollection collection, final SessionImplementor source) { comment the following lines. {{ // if ( !source.getLoadQueryInfluencers().getEnabledFilters().isEmpty() // && persister.isAffectedByEnabledFilters( source ) ) { // LOG.trace( "Disregarding cached version (if any) of collection due to enabled filters" ); // return false; // } }} |