Hibernate version: 3
How can I map a relationship to an entity with a composite primary key where one of the foreign keys in the source entity comes from another relationship?
In other words ...
Let's say I have a class ClassB with a composite primary key:
ClassB (pk1, pk2)
and ClassA has a many-to-one relationship with ClassB such that
Code:
ClassA.fk1 = ClassB.pk1
ClassA.ref2.fk2 = ClassB.pk2
where ref2 is a many-to-one relationship to ClassC.
So I need a mapping that will look like:
Code:
<class name="ClassA" table="CLASSA">
...
<many-to-one name="ref1" class="ClassB">
<column name="PK1"/>
<column-many-to-one name="ref2" class="ClassC" column="PK2"/>
</many-to-one>
...
</class>
Since we don't have a
column-many-to-one tag, I'm wondering if there's a good way to do this.
Thanks, Rishabh