-->
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: specifying constraints on related entities
PostPosted: Fri Jun 08, 2007 11:30 am 
Newbie

Joined: Fri Jun 08, 2007 11:26 am
Posts: 1
Hi,

According to the documentation, we can specify constraints upon related entities by navigating associations using CreateCriteria as follows :
IList cats = sess.CreateCriteria(typeof(Cat)) .Add( Expression.Like("Name", "F%")
.CreateCriteria("Kittens")
.Add( Expression.Like("Name", "F%") )
.List();

But this does not seem to fetch the data(lazy loading is enabled) for the related entities, although we can see the query being fired in the SQl profiler. Is there some setting Im missing??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 12:25 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Did you try SetFetchMode?

Code:
IList cats = sess.CreateCriteria(typeof(Cat)) .Add( Expression.Like("Name", "F%")
.SetFetchMode("Kittens", FetchMode.Eager)
.CreateCriteria("Kittens")
.Add( Expression.Like("Name", "F%") )
.List();


See section 12.5 of the docs.


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.