org.hibernate.cache.infinispan.InfinispanRegionFactory should default the "immutable-entity" to the "entity" cache settings

Description

Instead of WildFly cloning the "entity" cache configuration for "immutable-entity", it would be better if Hibernate defaulted to use the "entity" cache settings.

We just need to change org.hibernate.cache.infinispan.InfinispanRegionFactory from:

1 immutableEntityOverrides.setCacheName( DEF_IMMUTABLE_ENTITY_RESOURCE );

To:

1 immutableEntityOverrides.setCacheName( DEF_ENTITY_RESOURCE );

So that the immutableEntity defaults to the "entity" cache settings.

And remove DEF_IMMUTABLE_ENTITY_RESOURCE.

from irc conversation:

<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

Environment

None

Status

Assignee

Unassigned

Reporter

Scott Marlow

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major