[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4953) Inconsistent behavior when fetching cached subclass entities from 2L

Guenther Demetz (JIRA) noreply at atlassian.com
Thu Feb 25 08:10:48 EST 2010


Inconsistent behavior when fetching cached subclass entities from 2L
--------------------------------------------------------------------

                 Key: HHH-4953
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4953
             Project: Hibernate Core
          Issue Type: Bug
          Components: caching (L2)
    Affects Versions: 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1, 3.3.1, 3.2.5
         Environment: Hibernate3.5.0CR2,HSQLDB, EHCache as 2L-cache Impl
            Reporter: Guenther Demetz
         Attachments: Test2LCache.jar

Enabling the hibernate second-level cache is leading to inconsistent behavior when fetching cached subclass entities as opposed to fetching non-cached subclass entities.

For more informations, please see
https://forum.hibernate.org/viewtopic.php?f=1&t=1002880&p=2425931#p2425931

Testcase attached.

Cause:
IMHO the bug consists in the fact, that 
persister.getRootEntityName() instead to persister.getEntityName() is passed as 3thrd parameter 
to the constructor of CacheKey in most places where CacheKey is used, for example in DefaultLoadEventListener.java:


new CacheKey(
					event.getEntityId(),
					persister.getIdentifierType(),
					persister.getRootEntityName(),
					source.getEntityMode(),
					source.getFactory()

In this way the real entity name get swallowed and the type-saveness is not guaranteed anymore.



Workaround:

Subclass2 tofind = null;
try {
    tofind = (Subclass2) em.find(Subclass2.class,"identifier1");
}
catch (ClassCastException cc) {
   // swallow , this is a workaround
}

-- 
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