michael wrote:
Just use column_name="parente_id", a many-to-one will always refer to the parents id property.
thanks michael!
but it is still unclarified.
<key-many-to-one name="parent" class="Parent" >
<column name="id" /> here Parent table column name(which is id) has to be given,right???????it worked for me with this
</key-many-to-one>
consider this scenario,for different ids of child referring to different ids of parent (with different names).how will hibernate determine which id of child refers which id of parent (under which name).
is sequence of tags taken into consideration??
parent
======
id int
id_other int
name varchar
suppose there is a key here as (id,id_other,name)
child
====
child_id int
child_id_refer_parent int (refers id of parent)
child_id_other int (refers id_other of parent)
name varchar
suppose composite key here is (child_id,child_id_other,parent_id)
the mapping snippet for child will be,
<composite-id name="childPK" class="Child" >
<key-property name="childId" column="child_id"/>
<key-many-to-one name="parent" class="Parent" >
<column name="id" /> ?? here name is "id" but how to say it is referred by "child_id_refer_parent"
<column name="id_other" /> ?? here name is "id_other" but how to say it is referred by "child_id_other"
</key-many-to-one>
</composite-id>
thanks for your help.