Hibernate version: 2.1.4
I have three database tables (and hence three hibernate mapped pojos).
Table A, B, and C.
Table B has a composite id consisting of the primary key from A (a_id) and a second column of its own (b_id). This is a unique foreign key of (a_id, b_id).
Table B also has a <list> mapping to C on b_id which exists in C.
From B:
<composite-id unsaved-value="none">
<key-property name="b_id" type="long" column="b_id"/>
<key-many-to-one name="a" class="A" column="a_id"/>
</composite-id>
<list name="c">
<key column="b_id"/>
<index column="c_id"/>
<one-to-many class="C"/>
</list>
Table C is contains the following relationships back to A and B:
<many-to-one name="b" class="B" column="b_id" not-null="true"/>
<many-to-one name="a" class="A" column="a_id" not-null="true"/>
I get the following exception:
net.sf.hibernate.MappingException: Foreign key (COMMON.C [b_id])) must have same number of columns as the referenced primary key (COMMON.B [b_id,a_id])
So my question is, can this type of mapping be done? And if it can, how so? (If not in 2.1.x, can it be done in hibernate 3.x?)
Thanks,
Jay
|