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.