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.  [ 2 posts ] 
Author Message
 Post subject: One-To-Many Performance
PostPosted: Tue Sep 04, 2007 8:38 pm 
Beginner
Beginner

Joined: Wed May 02, 2007 12:24 am
Posts: 41
Hello,

I have a one-to-many relationship. And now that I look at nHibernate queries, it looks like nHibernate is firing a query per child object.

Is there a way I can instruct nHibernate to fire one query that loads all the child information from the db.

So for example instead of:
select _child.propA, _child.propB from Child _child where _childId = 0;
select _child.propA, _child.propB from Child _child where _childId = 1;
select _child.propA, _child.propB from Child _child where _childId = 2;

it would execute:
select _child.propA, _child.propB from Child _child where _childId in (0, 1, 2);

and then populate the child objects with that set?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 10:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
It is possible using either join fetching or sub-select fetching. When does each one got invoked depends on a number of things. The documentation on fetching strategy has all the detail information:
http://www.hibernate.org/hib_docs/nhibe ... e-fetching

_________________
Karl Chu


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