Hi
We are using Hibernate 3.0 and trying the following:
We have a 3 level inheritance hierarchy and are using table per subclass.
Class C extends Class B, Class B extends Class A.
The table structure is:
Table A has PK_A
Table B has PK_B
and a separate column PK_A (which obviously is a foreign key to PK_A in table A)
Table C has PK_C
and a separate column PK_B (which obviously is a foreign key to PK_B in table B)
ALL PKs have associated sequences in the database.
The class design is
Code:
class A
{
pkA;
}
class B
{
pkA;
pkB;
}
class C
{
pkB;
pkC;
}
The mapping looks like this:
Code:
<class
name="A"
table="TBL_A"
>
<id
name="pkA"
type="java.lang.Integer"
column="PK_A"
>
<generator class="sequence">
<param name="sequence">A_SEQ</param>
</generator>
</id>
<property...
</class>
<joined-subclass
name="B"
table="TBL_B"
extends="A"
>
<key column name="PK_A" />
<property
name="pkB"
type="java.lang.Integer"
column="PK_B"
not-null="true"
/>
</joined-subclass>
<joined-subclass
name="C"
table="TBL_C"
extends="B"
>
<key column name="PK_B" />
<property
name="pkC"
type="java.lang.Integer"
column="PK_C"
not-null="true"
/>
</joined-subclass>
I have the following questions:
1. is this the right approach ? and whether the mapping is correct.
2. Since "joined-subclass" tag will not support "id" tag like "class" tag does, how do i define the sequences for the separate PKs for the joined subclasses (e.g. PK_B and PK_C above)?
Thanks!
Amol