The entity and immutable-entity cache configurations are exactly the same. Rather than force users to define them, let's default the immutable-entity configuration to the entity configuration - the same way we do for the collection and natural id regions.
We just need to change org.hibernate.cache.infinispan.InfinispanRegionFactory from: {code} immutableEntityOverrides.setCacheName( DEF_IMMUTABLE_ENTITY_RESOURCE ); {code} To: {code} immutableEntityOverrides.setCacheName( DEF_ENTITY_RESOURCE ); {code}
So that the immutableEntity defaults to the "entity" cache settings.
And remove DEF_IMMUTABLE_ENTITY_RESOURCE.
from irc conversation: {quote} <pferraro> smarlow: question - what is the point of the immutable-entity cache configuration? <pferraro> smarlow: the config looks to be the same as for the entity cache configuration <smarlow> yup, weird huh? :) <smarlow> the problem is that its sort of immutable <pferraro> smarlow: are immutable entities stored in a separate region? <smarlow> Hibernate application code is not allowed to update the entity but can remove it <pferraro> where remove = evict? <smarlow> pferraro: @Immutable entities are stored in a separate cache. I mean "remove" as in delete from the database <pferraro> smarlow: I see, but why do we need a separate cache configuration? why can't we reuse the entity cache configuration? like we do for the collection region? <pferraro> smarlow: it would still get its own cache - but it would be configured the same as for mutable entities <smarlow> that sounds good, is that a code change or config file? <smarlow> the Hibernate equivalent is at https://github.com/hibernate/hibernate-orm/blob/master/hibernate-infinispan/src/main/resources/org/hibernate/cache/infinispan/builder/infinispan-configs.xml#L30 <pferraro> it would be logic to be handled via the infinispan region factory <pferraro> so - with the collection region - the InfinispanRegionFactory creates a cache based on a configuration called "entity", unless overridden <pferraro> I don't understand why we wouldn't do the same for immutable entities <pferraro> I'm thinking this should be changed here: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java#L520 <pferraro> lines 527-529, dictate the cache configuration used for collections if there is no "collection" cache config defined <pferraro> So, line 525 should do the same for immutable entities <pferraro> meaning, it should read: immutableEntityOverrides.setCacheName( DEF_ENTITY_RESOURCE ); <pferraro> that way, we don't need to define an superfluous "immutable-entity" cache configuration anywhere, since it is just a copy of the entity configuration {quote} |
|