WrongClassException in Single-Table Inheritance
-----------------------------------------------
Key: HHH-5954
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5954
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.1
Environment: 3.6.1 Final, MySql 5 & HSQLDB 2
Reporter: Jeff Crowe
A WrongClassException "loaded object was of wrong class" is randomly encountered
in the following situation:
Parent with single-table inheritance A
B extends A
C extends A
Parent with single-table inheritance X
Y extends X
Z extends X
B has field 'x' of type Y
C has field 'x' of type X
During initialization:
* The AbstractEntityPersister for class A is loaded and createLoaders() is called
* JoinWalker.walkEntityTree is invoked for class A
* The persister.getSubclassPropertyType iteration will encounter both fields 'x'
from B and C
* If C.x is encountered first, then the base type X is walked and everything works without
issues
* If B.x is encountered first, then the subtype Y is walked.
* When C.x is subsequently encountered, JoinWalker.isDuplicateAssociation will return
true for the field and the base type X is not added as an association for A.
* Later an attempt is made to query for C and a result C.x=Z is returned. A
WrongClassException is thrown because Z != expected type Y
This behavior is non-deterministic. The ordering that getSubclassPropertyType iterates is
determined by hashtable values and are therefore pseudo-random.
Known workaround:
* Specify (targetEntity=X.class) on B.x
* Alternately avoid duplicate field names on subtypes of a single-table entity hierarchy.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira