Hi there,

I have a class with a lot of many-to-one and one-to-many bags/lists.
Usually I want to lazy load most relations which is NHibernate its
default behavior.

I now have a situation where I want to eager load almost all
associations. To do this I did something like:

===============================
FetchMode mode = FetchMode.Eager; // or FetchMode.Select

MyClass result = session
   .CreateCriteria<MyClass>()
   .Add(Restrictions.IdEq(id))
   .SetFetchMode("A", mode)
   .SetFetchMode("B", mode)
   .SetFetchMode("C", mode)
   .SetFetchMode("D", mode)
   .SetFetchMode("E", mode)
   .SetFetchMode("F", mode)
   .SetFetchMode("G", mode)
   .SetFetchMode("H", mode)
   .SetFetchMode("I", mode)
   .UniqueResult<MyClass>();
===============================

This results is one query with lots of joins which is not what I
expected. I would expect that when I used "FetchMode.Join". When I use
"FetchMode.Select" it does not result in a eager load.

What is it that I am doing wrong? The only way I get it working is
when I set lazy="false" in all associations in the mapping file. But
the result of that is that I don't have lazy loading at all which I do
not want as that requires all queries to be adjusted to set the
FetchMode to "Lazy". By the way, I expected one database roundtrip but
it performs a roundtrip for each association. I can live with that but
it is not the most optimal.


I really want to increase the performance of this scenario's so any
suggestion is welcome!

Ramon

-- 
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