Hibernate version: 3.2.2
Hi folks,
I have a problem regarding the mixed inheritannce strategy.
Consider the following inheritance situation:
Code:
Parent
^
|
-------------------
| |
Child1 1 --- n Child2
I.e. Child1 and Child2 inherit from Parent and there exists a 1 to n relationship between Child1 and Child2.
I'm using the mixed inheritance startegy where I have three tables PARENT, CHILD11 and CHILD2. The mapping document looks basically like this (I omitted the properties for simplicity):
Code:
<hibernate-mapping>
<class name="Parent" table="PARENT">
<subclass name="Child1" discriminator-value="child1">
<set name="children2" cascade="all,delete-orphan" inverse="true">
<key column="FK_CHILD1"/>
<one-to-many class="Child2"/>
</set>
<join table="CHILD1">
<key column="CHILD1_ID"/>
<!-- properties -->
</join>
<subclass>
<subclass name="Child2" discriminator-value="child2">
<join table="CHILD2">
<key column="CHILD2_ID"/>
<many-to-one name="child1"
column="FK_CHILD1"
class="Child1"/>
</join>
<subclass>
</class>
</hibernate-mapping>
My problem is now, that the set association from Child1 to Child2 searches for the key column "FK_CHILD1" in the PARENT table and not in the joined CHILD2 table (the association from Child2 to Child1 works fine).
Is there any way to tell Hibernate, that this "children2" association has to find its foreign key in the joined table "CHILD2" instead of the PARENT table?
I already tried to specify the "table" attribute on the set or use a "foreign-key" attribute instead of the "column" attribute in the key element of the set. However, nothing worked :-(
Thanks in advance,
Joern