コレクションタイプマッピング
12037 ワード
1 public class StudentSet {
2 private int id;
3 private String name;
4 private Set<String> images = new HashSet<String>();
1 <?xml version="1.0"?>
2 <!DOCTYPE hibernate-mapping PUBLIC
3 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
4 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
5
6 <hibernate-mapping package="com.base.model">
7
8 <class name="StudentSet" table="t_studentSet"> <!-- -->
9 <id name="id" column="stuId"> <!-- , -->
10 <generator class="native"/>
11 </id>
12 <property name="name" column="stuName"/> <!-- -->
13
14 <set name="images" table="t_image"> <!-- -->
15 <key column="studentId"></key>
16 <element column="imageName" type="string"></element>
17 </set>
18 </class>
19
20 </hibernate-mapping>
1 <list name="images" table="t_imageList"> <!-- -->
2 <key column="studentId"></key> //
3 <list-index column="imageIndex"></list-index> //
4 <element column="imageName" type="string"></element>
5 </list>
1 <idbag name="images" table="t_images">
2 <collection-id type="int" column="imagesId"> //
3 <generator class="increment"/> //
4 </collection-id>
5 <key column="studentId"></key> //
6 <element column="imageName" type="string"></element>
7 </idbag>
1 <map name="students" table="student">
2 <key column="team_id"></key>
3 <map-key column="name" type="java.lang.String"></map-key>
4 <element column="description" type="string"></element>
5 </map>
6