I'm baffled by this...
I have a class Student. Student has a set, FirstChoices, a set, SecondChoices, and a set, Courses.
All three of these sets are of type Course.
I also have tables Student, Student_FirstChoices, Student_SecondChoices, and Course_Student.
For the *most* part, this goes fairly smoothly; however, when I do an inclusion check to see if the student has a firstchoice that matches the current course (so that I can highlight it) [if(student.getFirstChoices().contains(course))], hibernate appears to be getting mixed up and returning true for courses that are not in the firstchoices set, but *are* in the second choices set.
The debugger shows the course in secondchoices *and* in firstchoices but a select statement in the actual DB shows that the course is in secondchoices exclusively.
A buddy of mine at the office said that it has to do with the fact that I've got the same class referenced three different ways in the hbm file. I don't know if he's correct, but it doesn't seem right. There's nothing out of the ordinary with regards to a sql statement or out-of-bounds with regards to a DB.
Any ideas what could be causing secondchoices to leak into firstchoices? It doesn't seem to leak the other direction, nor does it appear to leak into courses
---snip from Student.hbm.xml--
<pre>
<set name="courses" table="Course_Student" lazy="true">
<key column="student_id"/>
<many-to-many column="course_id" class="org.voight.ats.dto.Course"/>
</set>
<set name="firstChoices" table="Student_Firstchoices" lazy="true">
<key column="student_id"/>
<many-to-many column="course_id" class="org.voight.ats.dto.Course"/>
</set>
<set name="secondChoices" table="Student_Secondchoices" lazy="true">
<key column="student_id"/>
<many-to-many column="course_id" class="org.voight.ats.dto.Course"/>
</set>
</pre>
|