Table per concrete class by R4R Team

The limitation of this approach is that if a property is mapped on the superclass, the column name must be the same on all subclass tables. The identity generator strategy is not allowed in union subclass inheritance. The primary key seed has to be shared across all unioned subclasses of a hierarchy.

Three tables are involved for the subclasses. Each table defines columns for all properties of the class, including inherited properties.

If your superclass is abstract, map it with abstract="true". If it is not abstract, an additional table (it defaults to PAYMENT in the example above), is needed to hold instances of the superclass.

There are two ways we can map the table per concrete class strategy. 

First, you can use <union-subclass>.

<class name="Payment">
    <id name="id" type="long" column="PAYMENT_ID">
        <generator class="sequence"/>
    <property name="amount" column="AMOUNT"/>
    <union-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
        <property name="creditCardType" column="CCTYPE"/>
    <union-subclass name="CashPayment" table="CASH_PAYMENT">
    <union-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!