Hi Stephane - Yes, I am pretty sure I remembered everything.
The only difference compared to your setup is that I have four nested levels and also need to specify some restrictions on the rows returned. I only want all the nested rows filled for one of the top- level entities. Anyway, thanks for letting me know. I will try your setup out and see how it behaves. Maybe I'll learn something. :-) Regards Thomas On 12 Okt., 10:23, Stephane Farges <[email protected]> wrote: > Hi, > > Yes, my Cities collections are loaded with this request without > further access to the database.(I'm sure of that, because when I use > the cities, the session is closed, so no lazy loading is possible) > Are you sure you didn't forget .SetFetchMode("Countries", > FetchMode.Eager) for one of the child collections ? > > Stephane > > On 9 oct, 15:45, Thomas Koch <[email protected]> wrote: > > > > > Hi Stephane - I have been fighting this issue as well and is also > > using the multicriteria. > > > Have you tried traversing your "Cities" collection after the load? > > Try iterating you Continents list, and for each Country in the > > continent, hit its Cities collection and see if it goes into the > > database. > > > I have been unable to make it work when more than one level. I usually > > get all the data in, but it seems that the nested collections is not > > initialized properly. > > Whenever I hit a collection at a nested at level 2+, NHibernate goes > > into the database. > > > If your setup is working correctly I would really be interested in > > knowing more. > > > Regards, > > Thomas > > > On 9 Okt., 11:33, Stephane Farges <[email protected]> wrote: > > > > I have found the solution below : > > > > IMultiCriteria vMC = CurrentSession.CreateMultiCriteria(); > > > vMC.Add<Continent>("continent", > > > CurrentSession.CreateCriteria<Continent>().SetFetchMode("Countries", > > > FetchMode.Eager).SetResultTransformer > > > (Transformers.DistinctRootEntity)); > > > vMC.Add<Country>("country", > > > CurrentSession.CreateCriteria<Country>().SetFetchMode("Cities", > > > FetchMode.Eager)); > > > > It's not as fast as I hoped it would be, but I'm not sure it's > > > possible to do better than this. > > > > On 8 oct, 18:13, Stephane Farges <[email protected]> wrote: > > > > > Hi, > > > > > I have a problem with selecting a deep object graph without Select N+1 > > > > or cartesian product. > > > > The model contains the classes Continent, Country and City. Each > > > > Continent contains a list of Country, and each Country contains a list > > > > of City, with bidirectionnal associations(Country has a Continent > > > > property and City has a Country property). > > > > > I want to load a list of all the Continents, with all the countries > > > > and cities. I know it is a lot of objects(around 2500 in total), but I > > > > don't have any other choice, and it was previously done with ADO.NET > > > > with acceptable performance. > > > > > I started by doing it the wrong way and I got either the Select N+1 > > > > problem or the Cartesian product problem, and it was not fast enough. > > > > > So I tried to do the following : > > > > > IMultiCriteria vMC = CurrentSession.CreateMultiCriteria(); > > > > vMC.Add<City>("city", CurrentSession.CreateCriteria<City> > > > > ()); > > > > vMC.Add<Country>("country", > > > > CurrentSession.CreateCriteria<Pays>()); > > > > vMC.Add<Continent>("continent", > > > > CurrentSession.CreateCriteria<Continent>()); > > > > > which gives good performance, but doesn't work because the relations > > > > are not initialized. > > > > > I have read this : > > > > > > > > http://ayende.com/Blog/archive/2007/06/20/Efficently-loading-deep-obj... > > > > but I'm not sure it applies in my case > > > > > Any idea how I can do this ? > > > > > Thanks, > > > > Stephane Farges.- Skjul tekst i anførselstegn - > > > > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn - > > - Vis tekst i anførselstegn - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
