tags:

views:

21

answers:

0

How would I generate the hbm file for the following scenario? In particular, I'm having trouble modeling the many-to-many relationship's composite key.....

Table: Course
Primary Key: CourseId

Table: Enrollment
Primary Key: CourseId, StudentId

Table: Fees
Primary Key: FeeId
Other Columns: Amount, Description

Table: Enrollment_Has_Fees (Pretend that the fees vary based on the student)
Columns: CourseId, StudentId, FeeId

I'm having trouble creating the hbm mapping for Enrollment_Has_Fees. I have the following in the Fee.hbm.xml file:

<set name="enrollmentFees" inverse="true" table="Enrollment_Has_Fees">
      <key column="feeId" />
      <!-- the next line does not work - this is the problem -->
      <many-to-many column="studentId" class="Enrollment" />
      <many-to-many column="courseId" class="Enrollment" />
      <!-- I almost need a notation like many-to-many columnS (note the plural "s") -->
</set>