|
Hi,
Hibernate version: 3.2.4
I have a map table that has columns like the following:
TABLE (
obj1_row_id,
obj1_item_id,
obj2_id
)
This has the following hibernate mapping file:
<hibernate-mapping>
<class name="ObjectMap">
<composite-id>
<key-many-to-one name="obj1" column="obj1_item_id" access="field" class="Object1"/>
<key-many-to-one name="obj1" column="obj1_row_id" access="field" class="Object1"/>
<key-many-to-one name="obj2" column="obj2_id" access="field" class="Object2"/>
</composite-id>
</class>
</hibernate-mapping>
Mapping file for Object1:
<hibernate-mapping>
<class name="Object1">
<id name="itemId" column="item_id" access="field"></id>
<property name="rowId" column="row_id" access="field"/>
</class>
</hibernate-mapping>
Mapping file for Object1:
<hibernate-mapping>
<class name="Object2">
<id name="itemId" column="item_id" access="field"></id>
</class>
</hibernate-mapping>
As you can see the table holds two properties from Object1 (this is for auditing purposes). When inserting into this table I would like to put:
Object1.itemId into ObjectMap.obj1_item_id column
Object1.rowId into ObjectMap.obj1_row_id column
Object2.itemId into ObjectMap.obj2_id column
But what actually happens is Object.itemId values get inserted into both ObjectMap.obj1_item_id and ObjectMap.obj1_row_id columns. I guess this makes sense as the Object1 <id> is itemId but is there anyway I can get the Object1.rowId put into ObjectMap.obj1_row_id column? I have looked through the docs but could not see any attributes for the <key-many-to-one> element that may help.
thanks
Steve
|