-->
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: left join fetch limitation
PostPosted: Thu Mar 27, 2008 2:50 pm 
Newbie

Joined: Fri Sep 21, 2007 11:09 am
Posts: 5
Hibernate version: 1.2

Is there a limit on the level of left join fetching that can be issued to hydrate an object graph with a single query?

I have a scenario that looks like the following:

select s from Survey s left join fetch s.SurveySections ss left join fetch ss.SurveySectionXRQuestions q left join fetch q.Answers where s.Id = ?

The SurveySectionXRQuestions mapping off of a SurveySection looks like this:


<map name="SurveySectionXRQuestions" inverse="false" lazy="true" cascade="none">
<cache region ="default" usage ="read-write" />
<key column="SurveySectionId"/>
<index column="QuestionId" type="Guid"/>
<one-to-many class="DosRios.SurveyManagement.SurveySectionXRQuestion, DosRios.SurveyManagement"/>
<filter name="IncludeActiveRecords" condition="'True' = Active"/>
</map>


The query will execute a single SQL statement, however it doesn't populate the Questions collection within the object graph until I iterate over it, as if it's lazy loading the collection. I was under the impression that the HQL query would override the lazy attribute within the hbm mapping. Any suggestions would be appreciated. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 4:19 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I don't think that HQL will override the lazy attribute. Have you tried it with lazy="false".

You can specifiy the maximun depth for joining in the configuration with "hibernate.max_fetch_depth", but I don't think, that's the problem here.

http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 11:04 am 
Newbie

Joined: Fri Sep 21, 2007 11:09 am
Posts: 5
Thanks for the suggestion, neither one of those provided any adjustments to the queries being generated, however I ended up changing the way we were doing left join fetches through object association to another alias and that helped dramatically. So, as an example, the query might have looked like this:

Select s from Survey s left join fetch s.Sections ss left join fetch ss.Content.Resources

and I changed it to:

Select s from Survey s left join fetch s.Sections ss left join fetch ss.Content ssc left join fetch ssc.Resources


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.