I need to map a single class to two tables (both with multiple columns primary key). Let's say TABLE1 has id1,id2,id3 and TABLE2 has id1,id2 as primary keys. Now when writing the mapping file I would do something like the following:
<hibernate-mapping package="beans">
<class name="TABLE1Class" table="TABLE1">
<composite-id name="table1PK" class="TABLE1PKClass">
<key-many-to-one name="id1" class="ID1Class" column="id1"/>
<key-many-to-one name="id2" class="ID2Class" column="id2"/>
<key-many-to-one name="id3" class="ID3Class" column="id3"/>
</composite-id>
<property name="someProperty" type="integer" not-null="true" column="x"/>
<join table="TABLE2">
<key column="id1" />
<!-- <key column="id2"/> The join tag accepts only one key tag!!!
How do I map the second key??? -->
<property name="propertyFromTable2" type="float" not-null="true"/>
</join>
</class>
</hibernate-mapping>
As you can see the join tag accepts only one key tag! How do I map the second id?
Kind Regards,
Despot
P.S.: Merry Christmas and a Happy and Productive New Year ;)
<key>
may contain multiple <column>
elements:
<key>
<column name = "id1" />
<column name = "id2" />
<column name = "id3" />
</key>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With