Hi,
What kind of mapping will we have if we have additional fields in middle table, other than the foreign keys connecting the 2 tables?
Existing:
Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid) <---middle table
Courses(key:courseid, column:description)
New:
Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid, ADDITIONAL FIELDS: 2 NON-KEY FIELDS: STARTDATE AND ENDDATE) <---middle table
Courses(key:courseid, column:description)
As seen above, i added startdate and enddate, 2 strings.
Existing hibernate will be like this:
Code:
<hibernate-mapping>
<class name="aaa.Student" table="STUDENT">
<id name="studentId" type="long" column="STUDENTID">
<generator class="assigned" />
</id>
<property name="name" type="string" length="200" column="STUDENTNAME" />
<set name="courses" table="STUDENTCOURSE" cascade="all">
<key column="STUDENTID" />
<many-to-many column="COURSEID" class="aaa.Course" />
</set>
</class>
</hibernate-mapping>
and
Code:
<hibernate-mapping>
<class name="aaa.Course" table="COURSE">
<id name="courseId" type="long" column="COURSEID">
<generator class="assigned"/>
</id>
<property name="courseName" type="string" column="COURSEDESCRIPTION"/>
</class>
</hibernate-mapping>
Will you let me know how the new one will be?