Hi guys,
Taking this comment as a starting point
http://vladmihalcea.com/2015/04/27/how-does-hibernate-read_only-cacheconcurrencystrategy-work/comment-page-1/#comment-3404
To reduce cache entities hydration, we could simply use the:
"hibernate.cache.use_reference_entries" setting, but that's too restrictive
as the AbstractEntityPersister prevents it when there are one-to-many
associations on an immutable entity:
public boolean canUseReferenceCacheEntries() {
// todo : should really validate that the cache access type is read-only
if ( ! factory.getSettings().isDirectReferenceCacheEntriesEnabled() ) {
return false;
}
// for now, limit this to just entities that:
// 1) are immutable
if ( entityMetamodel.isMutable() ) {
return false;
}
// 2) have no associations. Eventually we want to be a little
more lenient with associations.
for ( Type type : getSubclassPropertyTypeClosure() ) {
if ( type.isAssociationType() ) {
return false;
}
}
return true;
}
If the entity is immutable and all to-many associations are all marked with
"@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)"
we could allow the entity graph to be saved as an object reference.
This way we can save a lot of unnecessary CPU processing, spent with hydrating
each second-level cache entry.
Vlad
_______________________________________________
hibernate-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/hibernate-dev