-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Can we load the collection of a collection of a class?
PostPosted: Thu Apr 08, 2004 6:02 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
hi all,

imagine you have A (many to many) B (one to many) C
B and C are lazy loaded
querying like this
Code:
select a from A as a left fetch join a.bs

will return a with b collection loaded but c not initialized, that is what we want.

But is there a way to force collection c to be loaded too, something like
Code:
select a from a left fetch join a.bs b left fetch join b.c


i think "bs b left fetch join b.c" is incorrect.... because bs is a collection not an instance of B
I'm asking this because we are two in the forum needing this and that i'm not sure to understand the doc :
Quote:
Note that, in the current implementation, only one collection role may be fetched in a query.


And is there an impact of the parameter max_fetch_depth on this ?


Thanks,
Anthony[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 6:09 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, you can't use "fetch" for collections twice in a single HQL query. Imagine what kind of join and result set would be produced. With your "fetch b, fetch c" query you'd get a product/cross join, which would retrieve a huge result set (really huge). Hibernate will then throw away most of the data (distinct style) to flatten this big result table. This is less performant than two selects, so we don't even provide this "feature" right now. That way, everyone will have good performance without thinking too much about the generated SQL.

The max_fetch_depth parameter has no influence on any collection roles or outer join fetching for collections, it is only relevant for single-ended associations (one-to-one, many-to-one).

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
ok thanks for reply,
the only thing is about
"less performant than two selects"

there won't be only 2 sql generated but 1(for a with b loaded) + 1 (to load c) per b = n+1 queries.

but the performance seems to be ok (i'm working on a test with 600 generated queries) it take 20 seconds to load a 3 level object graph , i was just thinking about how to generate only one sql, if we can't, we can't, no problem.


Thanks,
Anthony


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 6:26 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, there are some usecases where it might make sense to outer join three (or four/five tables for many-to-many). I remember that there was a JIRA issue about that.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 7:49 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i took a look at jira, are you talking about this issue?
http://forum.hibernate.org/viewtopic.php?p=2197847

it's not the same problem isn't it?
Should i open a new issue?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:02 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, there is an issue in JIRA that discusses the case of more than one "collection fetch".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
argh, i've been searching for this issue for an hour, just can't get it i've made search on keyword "fetch" or "collection" but can't find.

Sorry to waste your time


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:54 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Christian, this was a private discussion the team had.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
too bad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 10:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh. Sorry :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 10:27 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
is there a way to be a virtual member of hibernate team? just to see this issue.... nop? ok no problem ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 10:32 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It's not really interesting. The conclusion was: "We don't want it right now, complexifies many other things as well, let's focus on things on TODO with higher priority".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 10:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Ok, anyway thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 11:33 am 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
That answers one of my earlier question.

Thanks to all
Shishir


Top
 Profile  
 
 Post subject: JIRA post
PostPosted: Mon May 17, 2004 8:06 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
http://opensource.atlassian.com/project ... wse/HB-668


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.