Hibernate version:
2.1
Name and version of the database you are using:
PostgreSQL 7.3.6
Question
I am trying to map a one-to-many relationship between two tables, but I need to use a different column in the parent table (ie not its primary key). Here's a sample mapping file:
Code:
<hibernate-mapping>
<class name="SubscriptionSendNumber" table="subscription_send_number">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">subscription_send_number_id_seq</param>
</generator>
</id>
<many-to-one name="subscriptionSend" column="subscription_send_id" not-null="true"/>
<many-to-one name="number" column="number_id" not-null="true"/>
<property name="threadId" column="thread_id" not-null="true"/>
<set name="messages" lazy="true" inverse="true">
<key column="threadid"/>
<one-to-many class="Message">
</set>
</class>
</hibernate-mapping>
The problem is the contained set isn't really a child table, and the key used here is not the primary key of the main table. So what I need to do is somehow specify a different column from the subscription_send_number table to use for the join (specifically, thread_id).
Is there any way to do this?
James