-->
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.  [ 11 posts ] 
Author Message
 Post subject: max fetch depth
PostPosted: Wed Feb 09, 2005 6:48 am 
Newbie

Joined: Mon Feb 07, 2005 10:26 am
Posts: 9
Hi,

In the book page 149, it is said that it is possible to load a graph of objects setting the max fetch depth property correctly.
However, page 261 it is said than only one collection can be fetched eagerly.
So i tested and it seems that page 261 is correct but not page 149.
Maybe i missed something ?

My pb is to fetch a graph of objects (depth = 4) . And when depth is > 3 i don't see a way to have a fixed number of sql statements for retrieving the graph.
Is it possible to have a fixed number of sql statements to load this graph ?
(The only solution i found is to limit the sql statements with batch size)

Thanks in advance for your help.
Francois


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 6:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read again, both statements are not in conflict. You can't fetch more than one collection per OUTER JOIN, otherwise you'd create a Cartesian product. This is also explained. By default, if you don't specify outer-join="true" anywhere, max_fetch_depth in Hibernate2 only affects *-to-one associations, because they default to "auto" mode.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 7:01 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I agree that the explanation on page 150 is not as easy to understand as it could be, especially since it is missing the Cartesian product limitation. I'll rewrite this in second edition anyway, since defaults are different in Hibernate3.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 8:39 am 
Newbie

Joined: Mon Feb 07, 2005 10:26 am
Posts: 9
Thanks for your answer Christian

I understand the max fetch depth for single point association.
The problem is for collection. I thought as it is said in page 148 that only one collection can be fetch per SQL SELECT (and not per OUTER JOIN).

So i don't understand how it is possible to load a Category with all the Bids.
Could you explain me please ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 8:55 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This might be a bug, you can't fetch Category -many-> Item -many-> Bid in one SELECT.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 9:16 am 
Newbie

Joined: Mon Feb 07, 2005 10:26 am
Posts: 9
OK. That's why in my first post i asked you for page 149 (in fact this is 150) because
"Setting this option to 3 joins all four tables in one
SQL statement and also loads all Bids"

Does that mean that we can't guarantee/know the number of select for loading a Category and we can only reduce them with batch loading ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 9:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
See my addition to the Errata.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 9:25 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And I really don't know why you would ever assume that you "can't guarantee the number of selects". You always can, you just have to understand how. There is no such thing as "random" fetching.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 9:53 am 
Newbie

Joined: Mon Feb 07, 2005 10:26 am
Posts: 9
I would like to explain you first how i load a graph with depth = 3.

Let's consider 3 tables A, B and C (A has a set of Bs, B has a set of Cs)
All collections are bidirectionnal and marked as lazy="true".

If i wan't to get A with all C.
The solution i use is to execute 2 HQL request in one session :
from A a where ...
from B b left join fetch b.cs where ... (only B for A are retrieved)
And then i need to initialize bs for A. I do it with Hibernate.initialize(bs).
=> 3 select
(I looked for a way to avoid calling Hibernate.initialize which execute an extra select even if the associated objects are in the session but i didn't find).

So with a graph of depth = 3, the number of select is fixed.
Is this solution correct ? is there a better method ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 11:27 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There is no other way, check "Cartesian product" with Google if you are unsure what it is. Also, please continue this on the User forum, I only answer direct questions about the book and CaveatEmptor here.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 11:50 am 
Newbie

Joined: Mon Feb 07, 2005 10:26 am
Posts: 9
Thanks a lot you for your answers and for the excellent book !!!!

It would have been great to continue our discussion (especially for a graph with depth = 4) but i understand that the User forum should be the right place to do it. The problem is that you're not on the User forum ;-)

Thanks again.
Francois


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