浅析Hibernate映射(五)——集合映射
集合映射主要包括:set、list、array、map的映射
对象模型:
映射后的关系模型:
映射文件:
<hibernate-mapping> <class name="com.jialin.hibernate.CollectionMapping" table="t_collection_mapping"> <id name="id"> <generator class="native"/> </id> <property name="name"/> <set name="setValues" table="t_set_values"> <key column="set_id"/> <element type="string" column="set_value" not-null="true"/> </set> <list name="listValues" table="t_list_values"> <key column="list_id"/> <list-index column="list_index"/> <element type="string" column="list_value"/> </list> <array name="arrayValues" table="t_array_values"> <key column="array_id"/> <list-index column="array_index"/> <element type="string" column="array_value"/> </array> <map name="mapValues" table="t_map_values"> <key column="map_id"/> <map-key type="string" column="map_key"/> <element type="string" column="map_value"/> </map> </class> </hibernate-mapping>