-->
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.  [ 7 posts ] 
Author Message
 Post subject: eager fetching question
PostPosted: Sat Jul 09, 2005 11:19 am 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Just a quick question.

I'm reading Hibernate in Action and in section 4.4.6 (p. 148), the following statement is made:

Quote:
At the time of this writing, Hibernate is able to fetch only one collection per SQL SELECT, so it isn't possible to declare multiple collections belonging to the same persistent class with outer-join="true".


I am just curious whether this is still true in 3.0.5.

By the way, guys, Hibernate is an incredible product.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 1:50 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
You can declare as many collections as you want for fetching using outer join now, but you have to be aware that it will result in cartesian product behaviour, which is almost certainly not what you want.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 3:15 pm 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Quote:
You can declare as many collections as you want for fetching using outer join now, but you have to be aware that it will result in cartesian product behaviour, which is almost certainly not what you want.


Indeed, it isn't, and I doubt I will often use eager fetching. I was simply interested for curiousity's sake. Thanks for the quick reply.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is actually useful to be able to do stuff like:

Code:
from Customer c join fetch c.orders o join fetch o.lineItems



This case does not create a cartesian product.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 4:04 pm 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
I'm risking asking a stupid question, here, since I didn't look this up before posting, but...

Code:
from Customer c join fetch c.orders o join fetch o.lineItems


Won't HQL ignore the mappings in this case anyway? That is, even if I map the relationships between Customer, Order, and LineItem as lazy, won't your query still result in an outer join, rather than several sequential SELECTs?

Sorry if that's in the docs, and I haven't looked it up (*sheepish grin*)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 4:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Sure, of course. But it was not clear from your question that you were talking about *mapping level* join fetching.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 09, 2005 4:36 pm 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Ah, indeed... I had not really made the distinction in my mind yet. Thanks for all the help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.