I want to create a set collection relationship between two classes Foo containing many Bar objects. However, due to data constraints I need to have the foreign key for the collection be the "customKey" property rather than the "id" property which usually serves as foreign key. I've experimented with a few configurations but no matter what config I try I cannot create the relationship that uses that "customKey/CUSTOM_KEY" as the foreign key.
Is there a way to create the relationship I desire.
The fragments below demonstrate what I would like to do.
Code:
<class name="Foo">
<id name="id" column="ORDER_ID">
<generator class="increment"/>
</id>
<!-- I wan't to use customKey as the foreign key rather
than id above assume that customKey is unique -->
<property name="customKey" column="CUSTOM_KEY"/>
<set name="bars" cascade="all">
<key>
<column name="CUSTOM_KEY" sql-type="VARCHAR(36)"/>
</key>
<one-to-many class="org.awp.Bar"/>
</set>
</class>
<class name="Bar">
<id name="id" column="BAR_ID">
<generator class="increment"/>
</id>
</class>
Thanks in adavance for any help.