-->
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.  [ 1 post ] 
Author Message
 Post subject: n+1 Optimization Issue
PostPosted: Thu Dec 23, 2010 3:32 pm 
Newbie

Joined: Thu Dec 23, 2010 3:25 pm
Posts: 1
have a contact entity and an institution entity. The contact has a one-to-one relationship with institution...

Code:
<one-to-one name="Institution" cascade="all-delete-orphan" class="Project.Core.Institution,Project.Core" lazy="proxy" />


When I retrieve ALL Contacts. A separate query is being run for each record return which queries the institution entity based on the ID. So if there are 10 contacts. There are 11 queries being run. Here is my HQL...

Code:
NHibernateSession.CreateQuery("select c from Contact c fetch join c.Institution i")
            .List<Contact>() as List<Contact>;


I've tried a number of variations, but am not able to solve the situation. Can anyone provide help as to what I may be doing wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.