I have some problems figuring out how to use the <join> element in Hibernate3. Suppose I have two tables Person and Addres. Address table has a column Id, and Person has a column AdrsId, which references Id column in the Address table. I am trying to get Hibernate to join Address row with Person row and map the result to an object of the Person class.
I tried:
<class name="Person" table="Person">
<id name="Id" column="Id" />
<join table="Address" >
<key column="Id" />
</join>
</class>
But it generates a query, which joins Person.Id with Address. Id instread of Person.AdrsId and Address.Id
If I do:
<class name="Person" table="Person">
<id name="Id" column="Id" />
<join table="Address" >
<key column="AdrsId" />
</join>
</class>
But it generates a query, which joins Person.Id with Address. AdrsId instread of Person.AdrsId and Address.Id
Do I need to add a many-to-one element inside the join element? If I do, then is there a way to avoid mapping a property inside the Person class to AdrsId column?
Thanks.
|