I am trying to fetch a collection with an inner join with the criteria api but I end up having lazy initialization errors when trying to access objects in the collection...
(Hibernate 3)
Code:
session.createCriteria(Course.class)
.setFetchMode("students", FetchMode.JOIN)
.createCriteria("students")
.list();
This creates the following SQL
Code:
select this_.idCourse as idCourse1_, this_.name as name0_1_, this_.publishDate as publishD3_0_1_, this_.mainLang as mainLang0_1_, student1_.idStudent as idStudent0_, student1_.firstname as firstname4_0_, student1_.surname as surname4_0_, student1_.idCourse as idCourse4_0_, student1_.idLanguage as idLanguage4_0_
from courses this_
inner join students student1_ on this_.idCourse=student1_.idCourse
Here it appears to be retrieving the data for the students but not actually storing these in the students collection. If I let it do an outer join instead the students are properly initialized.
Am I trying to do an inner join in the wrong way?
Thanks.