1.Set
因为Set是无序的,所以不需要索引,只需要新增一个字段用于存储Set值,
配置如下:
<set name="setValue" table="t_set_values">
<key column="set_id"></key>
<element type="string" column="set_value"></element>
</set>
其中的name为在实体类中Set的引用,set_value为新增的字段用于存储Set值,set_id参考了主键。
2.List
因为List是有序的,所以需要一个索引,再增一个字段用于存储List值。
配置如下:
<list name="listValue" table="t_list_values">
<key column="list_id"></key>
<list-index column="list_index"></list-index>
<element type="string" column="list_value"></element>
</list>
3.Array
需要索引值和新增字段。
配置如下:
<array name="arrayValue" table="t_array_values">
<key column="array_id"></key>
<list-index column="array_index"></list-index>
<element type="string" column="array_value"></element>
</array>
4.Map
新增字段用于存储key和对应的value。
配置如下:
<map name="mapValue" table="t_map_value">
<key column="map_id"></key>
<map-key type="string" column="map_key"></map-key>
<element type="string" column="map_value"></element>
</map>