-->
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: criteria.SetFetchMode(<CollectionProperty>, FetchMode.
PostPosted: Wed Apr 15, 2009 6:37 am 
Beginner
Beginner

Joined: Fri Sep 26, 2008 9:19 am
Posts: 20
Location: Belgium
NHibernate version: 2

hey guys,

i'm having difficulties with setting the FetchMode to Join after i've set a lazy binding on a one to many bag. (IList of objects)

when i do a getById i want to include all lazy bindings so i thought i had to set the fetchmodes of that collections to join.
with the fetchmode to join i'm getting the same object multiple times in my list of one to many relations. How can i fix this?

i've also added crit.SetMaxResults(1), then i'm only getting the first result in the one to many relation.

code:


Code:

ICriteria crit = session.CreateCriteria(typeof(TEntity));
crit.SetFetchMode("OneToManyList", FetchMode.Join);
crit.SetFetchMode("OneToManyList2", FetchMode.Join);
crit.Add(Expression.Eq("Id", id));
//crit.SetMaxResults(1);
ent = (TEntity)crit.UniqueResult();



so with the setmaxresults in comment i'll get TEntity that contains OneToManyList with the same item multiple times,
and with the SetMaxResults included i'm only getting the first item.


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.