-->
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.  [ 6 posts ] 
Author Message
 Post subject: Controlling lazy initialization of connected objects
PostPosted: Wed Mar 03, 2004 4:36 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Hi everyone,

we've got here a big data model with around 100 tables. They are *highly* interconnected.
So as the java app grows and maps more and more tables we end up with dozens of objects when loading even the most simple object.

I believe it's the *spirit* of O/R mapping to have your whole schema loaded in memory and at your disposal. And it's very convenient. Then you have to act on cache for optimization.

Nevertheless, in our case, we're systematically loading objects that correspond to features used once a year or so. It might be because of bad CDM design, but in some case you don't have much choice...

I was generally wondering whether it always makes sense to load all interconnected object and if there was a way to limit the connection depth (so kind of lazy initialization for many-to-one indeed)

Would the setting hibernate.use_outer_join allow me to limit the depth of loaded connected object, or is it just about controlling the amount of round-trip done to load all objects?

thanks for any hints


Last edited by nodje on Tue Jun 03, 2008 5:41 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 4:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can control object graph loading very finegrained by using the lazy="true" and outer-join="true" settings in your collection mappings. You can also use proxys for lazy loading on "one-relations". You can override lazy loading for queries by using "fetch join" in HQL. Hibernate gives you nearly complete control over how and when the graph is loaded.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 6:12 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
OK that sounds great.

The chapter on 12.1 on proxies is excellent.

One point remains fuzzy though, it's about hibernate.use_outer_join impact on outer-join attribute behavior:

The combination of hibernate.use_outer_join and outer-join="true|false" in association allows me to fine tune graph loading.
I read:
Quote:
auto (default) Fetch the association using an outerjoin if the associated class has no proxy


From that I suppose that outer-join=auto is not impacted by the hibernate.use_outer_join setting.
outer-join=false explicitely disable eager fetching (whatever hibernate.use_outer_join says)
outer-join=true enable eager fetching only if hibernate.use_outer_join is true

Is it correct

Many thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 6:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
hibernate.use_outer_join is rather deprecated, you should instead set hibernate.max_fetch_depth to something greater than 0 if you want outer-join fetching.

So hibernate.max_fetch_depth=0 -> no outer-join fetching at all. hibernate.max_fetch_depth > 0 -> outer-join fetching according to the outer-join attribute in the mapping.

hibernate.max_fetch_depth controls the maximum number of outer joins used in one statement during graph loading.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 6:39 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Note that it is only used for single ended associations, such as many-to-one and one-to-one. Collection valued associations are only loaded if you explicitely use outer-join="true" or an HQL/QBC eager fetch.

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 7:17 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Just to make things very clear:

you said:
Quote:
Collection valued associations are only loaded if you explicitely use outer-join="true" or an HQL/QBC eager fetch


That's only if the associated class is lazy="true". Otherwise collection valued associations are always loaded. Right?

The use of hibernate.max_fetch_depth has only impacts on the amount of SQL query generated by Hibernate (and can optionally force loading in lazy initialization cases)


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