Beginner |
|
Joined: Sun Jan 16, 2005 5:45 pm Posts: 24 Location: Atlanta
|
I would like to create query that returns a list of all entities (i.e. classes) but filters entities in a associated collection (i.e students). Is that possible using a createCriteria query? Consider two tables ClassInfo and StudentInfo. I want to query ClassInfo to get all classes but only include StudentInfo entities in the students collection where the student made an "A" in the class.
if I write something like
List<ClassInfo> classes = session.createCriteria(ClassInfo.class).createCriteria("students").add(Restrictions.eq("grade","A").list();
This restricts the class entities to classes where where at least one student made an "A". I would like the list to contain ALL classes and filter the student enties. In some cases the students list will be empty... This is ok and expected.
Is this possible with createCriteria? How?
Thanks in advance?
|
|