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.  [ 4 posts ] 
Author Message
 Post subject: set EAGER fetch mode problem
PostPosted: Thu Feb 17, 2005 11:23 am 
Newbie

Joined: Tue Feb 08, 2005 4:29 am
Posts: 7
Hi
I'm trying to override the lazy fetch mode (declared in the mapping xml file) by using the Criteria API and setFetchMode(FetchMode.EAGER). However, it seems that the collections of the objects i obtain aren't initialize. Is that normal ? Can someone help me ?


Top
 Profile  
 
 Post subject: Having the same problem
PostPosted: Wed Apr 13, 2005 5:51 am 
Newbie

Joined: Wed Apr 13, 2005 5:37 am
Posts: 2
Location: Munich, Germany
I'm having the same problem with Criteria API and hibernate 2.1.8:

List allInfo = session.createCriteria(ProductInfo.class) .setFetchMode("orderDetails", FetchMode.EAGER) .createCriteria("orderDetails", "orderDetails") .createAlias("orderType", "orderType") .createAlias("prices", "prices") .add(Expression.eq("orderType.name", orderType) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();

The order details for the product are not initialized after executing this even though the sql statement retrieved all the data from the database. The line:
setFetchMode("orderDetails", FetchMode.EAGER) doesn't seem to override the lazy default setting for the association.


Top
 Profile  
 
 Post subject: Found the reason for the 'problem' that i had
PostPosted: Thu Apr 14, 2005 5:19 am 
Newbie

Joined: Wed Apr 13, 2005 5:37 am
Posts: 2
Location: Munich, Germany
Setting the mapping of the association to EAGER does work, the second association is then, though set to EAGER as well, not being initialized for the following reason (taken from 'Hibernate in Action''):

Hibernate currently limits you to fetching just one collection eagerly. This is a reasonable restriction, since fetching more than one collection in a single
query would be a Cartesian product result. This restriction might be relaxed
in a future version of Hibernate, but we encourage you to think about the
size of the result set if more than one collection is fetched in an outer join.


So if you have problems with setting EAGER modes at runtime it's most probably because of this restriction or because of the following, already known and unfortunatelly still open issue:

http://opensource.atlassian.com/projects/hibernate/browse/HB-763

I still have the problem that i'd like to set the mapping for all the associations in the mapping files to lazy='true' and to deside each time when i run queries whether i' like to load and initialize all, some or none of the associated collections. I don't want to set outer-join property to "true", but lazy to "false" programmatically.

I still haven't found what i was looking for ....


Top
 Profile  
 
 Post subject: Set hibernate.max fetch depth property
PostPosted: Wed May 18, 2005 6:52 pm 
Newbie

Joined: Thu May 12, 2005 5:54 pm
Posts: 16
Did you try to set the max fetch depth property in hibernate.properties.
In your case a value of 2 must do the trick.
my assumption:
Yours is a Product -> Order -> OrderDetails relnship..


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