Hi Thomas,

I've experienced the same issue.
I too would like to know the reasons why this occurs.

Regards,
Craig.


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Thomas Koch
Sent: Friday, 17 July 2009 11:33 PM
To: nhusers
Subject: [nhusers] Fetching four level object graph in one go


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