1
我有三個表。學生可以註冊多門課程。如何做一對一的複合關係映射休眠
學生 RollNumber整數,字符串StudentName
場 CourseID整數,字符串CourseName
StudentCourses RollNumber整數,CourseID整數,AllotedRoom整數
Student.hbm .xml
<hibernate-mapping>
<class name="myPackage.Student" table="STUDENT">
<id name="ROLLNUMBER" type="integer">
<column name="ROLLNUMBER" />
</id>
<property name="STUDENTNAME" type="string">
<column name="STUDENTNAME"/>
</property>
</class>
</hibernate-mapping>
Course.hbm.xml
<hibernate-mapping>
<class name="myPackage.Course" table="COURSE">
<id name="COURSEID" type="integer">
<column name="COURSEID" />
</id>
<property name="COURSENAME" type="string">
<column name="COURSENAME"/>
</property>
</class>
</hibernate-mapping>
StudentCourses.hbm.xml
<hibernate-mapping>
<class name="myPackage.StudentCourses" table="STUDENTCOURSES">
<composite-id name="STUDENTCOURSES_pk" class="myPackage.STUDENTCOURSES_PK">
<key-property name="STUDENTID" column="STUDENTID"/>
<key-property name="COURSEID" column="COURSEID"/>
</composite-id>
<property name="ALLOTEDROOM" type="integer">
<column name="ALLOTEDROOM"/>
</property>
</class>
</hibernate-mapping>
對於在StudentCourses表中選擇的任何記錄,我想學生姓名以及 課程名稱。我的地圖文件應該如何看起來像這樣?