Thank you for replying pb00067,
Below is the hibernate configuration of what I am trying to achieve using annotations. According to the link I put in the original posting, this Inheritance
Strategy is "Table per subclass: using a discriminator". Notice that classes AbcNodeX and AbcNodeY map to the same table; they are distinguished from each other using the discriminator.
Unfortunately, we are working with a legacy database so I cannot change the database tables.
With annotations, when I run a query for a Node which should be of type AbcNodeX, Hibernate is returning a Node of type AbcNodeY.
Code:
<hibernate-mapping>
<class name="com.achme.Node" table="NODE">
<id column="nodeid" name="nodeid" type="long"/>
<discriminator column="defId" force="false" insert="true" not-null="true"/>
<property generated="never" lazy="false" name="name" type="java.lang.String">
<column name="NAME"/>
</property>
<subclass discriminator-value="12345"
name="com.achme.AbcNodeX" select-before-update="false">
<join fetch="select" table="ABC_NODE">
<key column="nodeid"/>
<property generated="never" lazy="false" name="type" type="string">
<column length="60" name="type"/>
</property>
</join>
</subclass>
<subclass discriminator-value="4567"
name="com.achme.AbcNodeY" select-before-update="false">
<join fetch="select" table="ABC_NODE">
<key>
<column name="nodeid"/>
</key>
<property generated="never" lazy="false" name="type" type="string">
<column length="60" name="type"/>
</property>
</join>
</subclass>
</class>
I am using hibernate 4.0
Any help is appreciated.
Thank you.