Java – mapping multi-level inheritance in Hibernate
•
Java
At present, I have such a structure:
A | +--B | +--C
It uses join tables to map one table per subclass For historical reasons, I also use the discriminator, so the current situation is as shown in section 9.1 3 of the hibernate manual
Question: how to extend the mapping of such a structure:
A | +--B | | | D | +--C
Can I map < subclass > < subclass > in Hibernate? What do I need < key >?
Solution
Not tested, but if you are using hibernate 3, according to the link you published
<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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码