-->
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: CreateSQLQuery Eager Load question (AddEntity, AddJoin)
PostPosted: Mon Feb 22, 2010 1:40 pm 
Newbie

Joined: Mon Feb 22, 2010 1:35 pm
Posts: 3
I have a stored procedure i would like to run to popoulate my entity.

IQuery iq = session.CreateSQLQuery("exec myStoredProcedure")
.AddEntity("s", typeof(Shop))
.AddJoin("t", "s.Types");


var test = iq.List<Shop>();


I have written this stored procedure to get around an N+1 problem with
Paging.


Shop has a Many to Many relationship with Type.


If i remove the AddJoin and select shop.* from my stored procedure,
then my shop entity loads up, but obviouly doesnt eager load the
types.


I think i need to use the AddJoin method to eager load my types but
cant seem to get it right.


I selected
----- shop.*, shopTypes.*, types.*
----- shop.*, types.*


but nothing seems to work.


I have even written the hql for this, and then added the selection
columns from this, but still it doesnt work.


Any ideas???


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.