[hibernate-dev] should immutable entities in the second level cache be invalidated when they are removed from the database?

Scott Marlow smarlow at redhat.com
Tue Jan 5 10:35:07 EST 2016


I missed adding the WildFly clustering configuration for the Hibernate 
immutable-entity cache.  I opened WFLY-5923 [1] for adding the cache but 
am unsure of whether org.hibernate.annotations.Immutable means that the 
application handles clearing the 2lc of stale immutable entities or if 
that should happen automagically when immutable entities are removed 
from the database.

In a cluster, I expect that the performance of caching 
immutable-entities, would be faster if we assume they will not be 
invalidated from the 2lc (e.g. let applications clear them from the 
cache).

Since we are using Infinispan for the 2lc in WildFly, I would like to 
use an Infinispan simple-cache for immutable-entities, which does no 
invalidation.  However, just because I would like to do this, doesn't 
make it right. :-)  Which is why I'm asking, what the design intention 
is, so I can configure the WildFly clustering configuration (for 
immutable entities), to align with the intent.

 From Immutable javadoc:
"
Mark an Entity or a Collection as immutable. No annotation means the 
element is mutable.

An immutable entity may not be updated by the application. Updates to an 
immutable entity will be ignored, but no exception is thrown.
...
"

Scott

[1] https://issues.jboss.org/browse/WFLY-5923



More information about the hibernate-dev mailing list