[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5820) Improved second level caching for immutable entities

Nicolas Estrada (JIRA) noreply at atlassian.com
Wed Jan 5 07:49:05 EST 2011


Improved second level caching for immutable entities
----------------------------------------------------

                 Key: HHH-5820
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5820
             Project: Hibernate Core
          Issue Type: Improvement
          Components: core
         Environment: Hibernate 3.6.0.Final, EhCache 2.3.0, MySQL
            Reporter: Nicolas Estrada
            Priority: Minor


A description of my problem and a fix is available here:

https://forum.hibernate.org/viewtopic.php?f=1&t=1008946&p=2440121#p2440121

The problem is as follows:

I am using simple POJOs, no dynamic updates, no formula properties, some using a single table and others spanning multiple tables. In my special case they are also IMMUTABLE. Now when an EntityInsertAction (in my case from doAfterTransactionCompletion()) wants to update the cache is invokes the method isCachePutEnabled().

For single table entities it works fine but when the entity spans multiple tables (ie. getTableSpan() > 1), isCacheInvalidationRequired() returns true, which I think stems from the fact that a concurrent cache may have simultaneous locks on different CacheKeys pointing to the same entity (not sure).

Now the transaction was successfully completed, ie. an immutable entity was successfully persisted into the datastore. Why then can't it be inserted in the second level cache? The culprit is the table spanning check. I think that in a special case if the entity is immutable it should override the latter.

A fix which seemed possible would be to version the entities. However, since they are immutable, I'm opting for using a read-only cache mode for the entities. And when I try to update the version I get an UnsupportedOperationException in the ReadOnlyEhcacheEntityRegionAccessStrategy from Ehcache when it tries to invoke lockItem() from the EntityUpdateAction in order to upgrade the version. Versions are not a solution in my case.

Any thoughts on the matter would be appreciated. Thank you

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list