我需要将一个类Map到两个表(都有多个列主键)。假设TABLE 1有id 1,id 2,id 3,TABLE 2有id 1,id 2作为主键。现在,在编写Map文件时,我将做如下操作:
<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>
如您所见,join标记只接受一个key标记!如何Map第二个Id?
1条答案
按热度按时间n7taea2i1#
<key>
可以包含多个<column>
元素: