-->
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: EagerFetch with SELECT (not outer-join) on Child required
PostPosted: Thu May 24, 2007 6:35 am 
Newbie

Joined: Wed May 16, 2007 7:39 am
Posts: 5
Hibernate version: 1.2.0.3001

Our requirement is to use EagerFetch for the Children by firing a separate SELECT query on the child table.

With FetchMode.Eager we are having a left outer join with a parent to retrieve a list of children, this is not the way I would write SQL to do it because in the results we are duplicating all the parent data for each child.

With criteria.SetResultTransformer(CriteriaUtil.DistinctRootEntity), these duplicate results are no doubt eliminated but the fact that it is filtered out after getting duplicates from the db doesn't sound efficient way of tackling the problem (though NHibernate itself does it internally) .

Marking lazy="false" in schema and using FetchMode.Select in the source code gives the desired behaviour. However, I can't switch back to lazy loading on scenarios when we dont need children in different scenario.

Any suggestions on tackling this issue would be highly helpful.


Top
 Profile  
 
 Post subject: Re: EagerFetch with SELECT (not outer-join) on Child require
PostPosted: Thu May 24, 2007 8:25 am 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
kris11 wrote:
Hibernate version: 1.2.0.3001

Our requirement is to use EagerFetch for the Children by firing a separate SELECT query on the child table.


If you want to use a seperate select, why is it important that it is fetched eagerly? Is this because you will be closing the session before you need to access the property?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 8:35 am 
Newbie

Joined: Wed May 16, 2007 7:39 am
Posts: 5
Yes. You sensed it right. We close the session after retrieval is done and the results are passed back to the client back from the Server. It is the client which uses it.


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.