集合映射
Set、List、Array、Bag、Map
- 元素:
- 可以映射
java.util.Set 接口的属性。
- 元素没有顺序且不允许重复。
- 元素:
- 可以映射
java.util.List 接口的属性。
- 有顺序,需要在集合属性对应的表中用一个额外的索引保存每个元素的位置。
- 、 元素:
- 可以映射
java.util.Collection 接口的属性。
- 元素可重复,但不保存顺序。
- 元素:
- 可以映射
java.util.Map 接口的属性。
- 元素以键/值对的形式保存,也是无序的。
- 、:
示例代码
元素
private Set<String> hobbies;
<set name="hobbies" table="student_hobby">
<key column="student_id"/>
<element type="string" column="hobby_name" not-null="true"/>
</set>
元素
private List<String> hobbies;
<list name="hobbies" table="student_hobby">
<key column="student_id"/>