[hibernate-issues] [Hibernate-JIRA] Created: (HHH-7186) Enabling 2nde level cache with filtered collections.
Lucas POUZAC (JIRA)
noreply at atlassian.com
Mon Mar 19 12:41:50 EDT 2012
Enabling 2nde level cache with filtered collections.
----------------------------------------------------
Key: HHH-7186
URL: https://hibernate.onjira.com/browse/HHH-7186
Project: Hibernate ORM
Issue Type: Improvement
Components: core
Affects Versions: 4.1.1, 4.0.1, 3.3.1
Reporter: Lucas POUZAC
Actually, when we use filtered collection, the 2nde level cache can't be activate.
Below, the code snippet :
{code:title=org.hibernate.engine.loading.internal.CollectionLoadContext.java|borderStyle=solid}
/**
* Add the collection to the second-level cache
*
* @param lce The entry representing the collection to add
* @param persister The persister
*/
private void addCollectionToCache(LoadingCollectionEntry lce, CollectionPersister persister) {
...
if ( !session.getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( session ) ) {
// some filters affecting the collection are enabled on the session, so do not do the put into the cache.
LOG.debug( "Refusing to add to cache due to enabled filters" );
// todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
// but CacheKey is currently used for both collections and entities; would ideally need to define two seperate ones;
// currently this works in conjuction with the check on
// DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
// cache with enabled filters).
return; // EARLY EXIT!!!!!
}
...
}
{code}
{code:title=org.hibernate.event.internal.DefaultInitializeCollectionEventListener.java|borderStyle=solid}
/**
* 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;
}
...
}
{code}
Could you add this feature ?
For example, we should modify the cache key to add the filter name.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list