-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can I force a eager load of the entire dependency graph
PostPosted: Sun Aug 22, 2004 4:19 pm 
Newbie

Joined: Fri Aug 20, 2004 1:13 pm
Posts: 10
Hibernate version:2.1.6

I have a persistent object with very many dependent objects (Sets mostly). Is there a way I can force an eager load of all the dependent objects? One way it to put it in the mapping file but I dont want to always eager load. Another way is to specify in the hibernate sql all the "outer join fetch" clauses but that is a pain bc there are so many.

I could write something with reflection to find all the Sets, Lists, etc of a POJO and call the getters to force lazy loading. That seems a bit sloppy. Any other thoughts?

_________________
-alan


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 22, 2004 5:19 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
all the "outer join fetch" clauses but that is a pain bc there are so many


sorry but even with a query : only one collection can be fetch... you'll need one fetched query per to-many assocations

example
A--*B
|
|
*
C

you need 2 queries to fetch the entire graph
from A a join fetch a.bs
and
from A a join fetch a.cs

you can see workarounds in hibernate in action, you'll have to choose between efficient lazy loading, eager fetching and smart number of queries

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 22, 2004 5:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Perhaps you want to look at batch fetching for this.

If you thinkabout it, what you described is a real performance bug, you would end up with a SQL result set with many, many rows (a cartesian product between all collections).


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