To create entries you will need to use
3 classes and 3 mappings.
e.g. department, team, member
When reading entries a criteria query will help you and will not load anything you will not need.
As lazy is the default, the teams of a department will not be automatically loaded when the department is loaded.
To read all membersand the department info you may create a query as followed:
Code:
List results = session.createQuery("select m,d from Member m join m.team as t join t.department as d where d= ?")
.setEntity(0, department)
.list();
for (Iterator iter = results.iterator(); iter.hasNext();) {
Object tuple[] = ( Object[]) iter.next();
log.debug("--"+(Member)tuple[0]);
log.debug((Department)tuple[1]);
}
tx.commit();
Please rate if this is ok for you!
Regards
Sebastian