I have Teacher entity and Student entity like this :
class Teacher { public Long id ; public Set<Student> students; }
class Student { public Long id ; public Teacher teacher ; public Boolean passedSemester1; public Boolean passedSemester2; }
You can assume my tables have the a the following structure.
Teacher and Student has a bidirectional one to many relationship. Student table manages the foreign key .
I need to find out the Teachers whose students all passed semester1 and semester2.
Actually I also need to search :
all failed to pass both semester1 and semester2 , all passed semester1 but failed to pass semester2 , all failed to pass semester1 but passed semester2 .
You could write any one of this queries , others should be no big differences.
In order to not cause other misunderstandings , I abstract my real problem into this simple one. I need join the two tables to do other complex queries , so it's not so easy as just to query the students table.
I am using Hibernate 3.1.3 , no patches has been applied .
Thanks !
|