eager selecting grand-child relations is dangerous, as it will create
a Cartesian result. I cannot remember the math but there is
information about this on the web. Basically take care when loading so
much data all at once.

You may be better to Eager select the Articles and then Select select
the grandchildren. Or load the (great)grandchildren separately and
manually add them into the root product.
Another option is to use MultiQuery to build up the root entity.

On Jul 18, 1:58 am, Raul Carlomagno <[email protected]> wrote:
> use .SetFetchMode("Articles", FetchMode.Eager) for each entity
> involved, this way, you force nh to get the entire graph in one hit
> (lazy load is disabled), take care about duplicates, use distinct
> result transformer
>
> On Jul 17, 10:32 am, Thomas Koch <[email protected]> wrote:
>
> > Hi - I am trying to load a graph of objects in one to the database and
> > it works ... almost.  :-)
>
> > My domain: Report -* Articles -* Volumes -* Deliveries
>
> > I have an Id from the Report. Now I want to load the Report entity
> > with all the Articles, Volumes and Deliveries collections (bags)
> > initialized.
>
> > I can do:
>
> >             var transformer = new DistinctRootEntityResultTransformer
> > ();
>
> >             var reportCriteria = NHibernateSession.CreateCriteria
> > (typeof(Report));
> >             reportCriteria.Add(Restrictions.IdEq(reportId));
> >             reportCriteria.SetResultTransformer(transformer);
>
> >             var raCriteria = reportCriteria.CreateCriteria("Articles",
> > JoinType.InnerJoin);
> >             raCriteria.SetResultTransformer(transformer);
>
> >             var vaCriteria = raCriteria.CreateCriteria("Volumes",
> > JoinType.InnerJoin);
> >             vaCriteria.CreateCriteria("Deliveries",
> > JoinType.InnerJoin);
> >             vaCriteria.SetResultTransformer(transformer);
>
> >             var reports = reportCriteria.List<Report>();
> >             report = reports.FirstOrDefault();
>
> > Which will load all the data for me, however when I begin traversing
> > the object graph from Report, it will go to the database again.
>
> > Can anyone tell me what I am doing wrong?
>
> > Kind regards
> > Thomas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to