-->
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.  [ 4 posts ] 
Author Message
 Post subject: HQL and eager/lazy loading
PostPosted: Fri Aug 19, 2005 2:23 am 
Newbie

Joined: Tue Aug 16, 2005 8:28 am
Posts: 15
I have a Person that has a Set of Addresses.

I need to find the Person using an HQL like this:

from com.oreilly.hh.Person as person
where upper(person.name) = upper(:person)

Now I want that the addresses load eagerly, so I set the outer-join = true.

<set name="addresses" inverse="true" outer-join="true">
<key column="PERSON_ID"/>
<one-to-many class="com.oreilly.hh.Address"/>
</set>

But I still find that eager-fetching does not happen. I find that immediate fetch does happen.

Now if I change the HQL to

from com.oreilly.hh.Person as person
left join fetch person.addresses
where upper(person.name) = upper(:person)

I see eager fetch happen.

My question is:

Is it that the HQL overrides the outer-join in the Person.hbm.xml mapping all together?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 7:46 pm 
Newbie

Joined: Tue Aug 16, 2005 8:28 am
Posts: 15
anybody faced such scenarios?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2005 1:12 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Maybe this is your problem:

http://www.hibernate.org/117.html#A18

"HQL queries always ignore the setting for outer-join defined in the mapping document. This setting applies only to associations fetched using get() or load(), Criteria queries, and graph navigation. If you need to enable eager fetching for a HQL query, use an explicit LEFT JOIN FETCH."


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2005 10:50 am 
Newbie

Joined: Tue Aug 16, 2005 8:28 am
Posts: 15
wonderful dennis, thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.