Hello. Using Hibernate 2.0.3. I'm having problems creating a Map which represents a many-to-many relationship.
I chose a many-to-many between students and classes as a classical example.
I want a student to have a Map of classes, indexed by classId.
My mapping document looks like this:
Code:
<hibernate-mapping>
<class
name="tests.Student"
table="Student"
dynamic-update="false"
dynamic-insert="false">
<id name="studentId" column="studentId" type="long">
<generator class="hilo" />
</id>
...
<map
name="classes"
table="StudentClass"
lazy="true"
sort="unsorted"
inverse="true"
cascade="none">
<key column="studentId" />
<index column="classId" type="long" />
<many-to-many
class="tests.Class"
column="classId"
outer-join="auto"
/>
</map>
</class>
</hibernate-mapping>
The error I get is this:
net.sf.hibernate.MappingException: Repeated column in mapping for collection: tests.Student.classes column: studentId
I can see that I'm mapping both the index and the many-to-many to classId, but isn't this precisely what I want to do?
Thanks in advance,
Assaf