Hi
There is no implicit inheritance hierarchy in the classes involved - so I don't understand how mapping a hierarchy would help me. Perhaps you could elaborate?
PayProfile and Payslip are two completely different classes. Both however have a relationship with an IncomeEntry in a one-to-many manner. In the case of a Payslip, the IncomeEntries represent the payslips income entries, whereas in the case of the PayProfile the IncomeEntries represents the payprofiles income entry.
To solve the issue I have created two new classes, PayslipIncomeEntry and PayProfileIncomeEntry. These classes are mapped to payslip_incomeentry and payprofile_incomeentry respectively. The IncomeEntry class is then mapped as a component in each of these classes. This allows me to re-use the class.
i.e.
Code:
<hibernate-mapping>
<class
name="PayslipIncomeEntry" table="payslip_incomeentry">
<id name="id" column="id" type="java.lang.Long" unsaved-value="null">
<generator class="native" /
</id>
<component name="entry" class="IncomeEntry">
....
</component>
</class>
</hibernate-mapping>