Could you please post an example of your mapping and query? 2009/4/1 Morten Haug <[email protected]>
> > Hi Roger, thanks for replying. > > Just some more explanation. Type3 has no object reference to Type2, > there's just a bag of Type3's with a reference to a column (Type3 can > have other Type-parents). I'm not sure if it has anything to do with > error I'm getting though, which is: > > When I use this HQL: > > "from Type2 a inner join fetch a.Type3List where a.Type1=:type1id" > > I get a "NHibernate.LazyInitializationException: failed to lazily > initialize a collection, no session or session was closed" when it > tries to set the Type3List. And the session is definitively open. > > Using similiar approach with ICriteria yields the same results. > > Best regards, > Morten Haug > > On 1 Apr, 09:53, Roger Kratz <[email protected]> wrote: > > Either by using three different selects, > > [get type3 where xxx] > > [get type2 where xxx] > > [get type1 where xxx] > > ...preferable batching these queries using MultiCriteria/Query > > > > ...or... > > Getting a wider set back, using joins. > > SetFetchMode("Reference", FetchMode.Join), Criteria > > join fetch, HQL > > > > /Roger > > > > > > > > -----Original Message----- > > From: [email protected] [mailto:[email protected]] On > Behalf Of Morten Haug > > Sent: den 1 april 2009 08:42 > > To: nhusers > > Subject: [nhusers] How to eager load a object hierarchy in one batch > > > > Hi, lets say I have a structure like this: > > > > Type1 > > |--Type2 > > | |--Type3 > > | |--Type3 > > |--Type2 > > | |--Type3 > > | |--Type3 > > > > How could I best fetch this tree (no lazy loading)? "Out of the box" > > it looks like it for each of the Type2's, it makes a select for its > > collection of Type3's. What I'd like is to batch it up into one select > > for all Type3's, and map them correctly into their respective Type2 > > parent. > > > > Best regards, > > Morten Haug– Skjul sitert tekst – > > > > – Vis sitert tekst – > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
