• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mixing inheritance strategies for multi-level inheritance in Hibernate

 
Marco Tulio Borges
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vijay Kalakoti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic