Currently I have a structure like this:
A
|
+--B
|
+--C
It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in Section 9.1.3 of the Hibernate manual.
Question: How do I extend the mapping for a structure like this:
A
|
+--B
| |
| D
|
+--C
Can I <subclass>
a <subclass>
in the hibernate mapping? What <key>
s do I need?
From stackoverflow
-
not tested but, according to the link you posted if you are using hibernate3
<hibernate-mapping> <class name="A" table="A"> <id name="id" type="long" column="a_id"> <generator class="native"/> </id> <discriminator column="discriminator_col" type="string"/> <property name="" type=""/> <!-- ... --> </class> <subclass name="B" extends="A" discriminator-value="B"> <!-- ... --> </subclass> <subclass name="D" extends="B" discriminator-value="D"> <!-- ... --> </subclass> <subclass name="C" extends="A" discriminator-value="C"> <!-- ... --> </subclass> </hibernate-mapping>
Henning : Seems to work. Thank you very much! -
How would this be done with annotations?
-
See here - the hibernate team says: "impossible" :)
Michal Bachman : that's an answer to the annotation question...
0 comments:
Post a Comment