-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: inner joins with criteria query
PostPosted: Wed Mar 23, 2005 8:42 am 
Newbie

Joined: Sun Aug 31, 2003 12:04 pm
Posts: 8
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 9:18 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
FetchMode.EAGER


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 9:42 am 
Newbie

Joined: Sun Aug 31, 2003 12:04 pm
Posts: 8
FetchMode.EAGER is deprecated in 3.0 which is why I was using FetchMode.JOIN. I just tried EAGER too with no luck but I guess they are functionally equivalent anyway :-P


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.