<element>
和<composite-element>
之间有什么区别?我在标记中看到了<composite-element>
和<element>
个标记。这些元素是用于收藏吗?在什么情况下这些元素都适用?
答案 0 :(得分:2)
<element>
。值。请参阅6.2.4. Collections of values and many-to-many associations
<set name="names" table="person_names">
<key column="person_id"/>
<element column="person_name" type="string"/>
</set>
<composite-element>
用于映射components的集合,即由简单类型组成的哑类。这个例子来自8.2. Collections of dependent objects:
<set name="someNames" table="some_names" lazy="true">
<key column="id"/>
<composite-element class="eg.Name"> <!-- class attribute required -->
<property name="initial"/>
<property name="first"/>
<property name="last"/>
</composite-element>
</set>