I want to use FetchMode.JOIN to get around lazy loading. I have an application which displays a list of students. Once a student is selected, I need to provide details for this student. This is when I get the lazy loading errors. The students are structured like this.
The student object contains a list of enrollments objects. The enrollment object contains a course object. The course object contains a list of sessions and a list of homework assignments... etc.
I looked through a number of postings on this forum and it looks like I can get around lazy loading by setting the fetchmode.
Criteria newCriteria = session.createCriteria(Student.class);
newCriteria.setFetchMode("enrollments", FetchMode.JOIN);
This does seem to work but only to the enrollment level. When I try to get to the course object which is within enrollment, it doesn't seem to work. I'm trying to do it like this.
newCriteria.setFetchMode("enrollments.course", FetchMode.JOIN);
How should I get to the course object?
Any help will be greatly appreciated.
Henry
|