| Author |
Mixing inheritance strategies for multi-level inheritance in Hibernate
|
Marco Tulio Borges
Ranch Hand
Joined: Sep 14, 2004
Posts: 45
|
|
Hello, there Ranch folks! I'm facing a problem with multi-level inheritance in Hibernate, mixing inheritance strategies. I have not found any examples or solutions to this particular problem on the web, so let me try to describe it: This is my class hierarchy: A (abstract class) |-B (abstract class) | |-C | |-D |-E In other words: C and D extend B while E and B extend A. Classes B and A are abstract. My database is set this way: I have a table named "table_A", a table named "table_B" and a table named "table_E". I'm using Java 5 with Hibernate 3.2.1 (with Annotations 3.2.0). The mapping looks like this: The real problem happens when I'm trying to query for a list of entities of type A. Looks like Hibernate is not trying to instantiate C and D by the single table strategy. Hibernate is trying to resolve C and D using the InheritanceType.JOINED strategy, looking for tables with names "C" and "D", since the name of the table is not specified. Apparently Hibernate is ignoring the second strategy (InheritanceType.SINGLE_TABLE). I read somewhere (hard to find out where, after so many searches) that Hibernate can handle mixing strategies in this multi-level inheritance problem. What am I doing wrong?  [ January 11, 2008: Message edited by: Marco Tulio Borges ]
|
.: SCJP 1.4 (95%) / SCWCD 1.4 (91%) / SCBCD (77%) :.
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us." - Calvin
|
 |
Vijay Kalakoti
Greenhorn
Joined: Nov 08, 2004
Posts: 2
|
|
Check this link: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1175 It seems like it's possible atleast with xml mapping. Not sure about annotations though...
|
Any problem in Computer Science can be solved by adding a level of indirection -- Ion Stoica
|
 |
 |
|
|
subject: Mixing inheritance strategies for multi-level inheritance in Hibernate
|
|
|