Hi Zoid, thanks for your post. This definitly explains the case I described in my second post. I simply forgot that when using HQL the mapping configuration regarding joins is ignored. I am still not entirely sure what happens in the szenario of my first post (as I do not use HQL here but use NHibernateUtils to initialize a lazy collection) but I am using batch-fetching for both cases now anyway :-)
Thanks again, Ronald On 22 Apr., 19:57, zoid <[email protected]> wrote: > Hi Ronald, > thanks for the tip. The max_fetch_depth is for outer joins like <many- > to-one> and <one-to-one> only, so my statement seems to keep > right when A has a list of B has a list of C. What of course is not > your point here. > So after reading this chapter of 'NHibernate in Action' it seems clear > to me. > > Eager fetching defined in the mapping will only be noticed on Criteria > queries: > > >Keep in mind that eager fetching strategies declared in the mapping metadata > >are effective only if you use > >retrieval by identifier, use the criteria query API, or navigate through the > >object graph manually. Any HQL > >query may specify its own fetching strategy at runtime, thus ignoring the > >mapping defaults > > If you use HQL you have to add the 'fetch' - Keyword. > It says nothing about fetching with a Dao like getAll(), so i don't > know what is used here. > > In a Criteria this should work: > > CreateCriteria(typeof(a)) > .SetFetchMode("B", FetchMode.Join) > > In HQL you could do this: > > from A > outer join fetch A.B > where a.something = .... > > And this should definitely work. I use it and don't have any problems. > So hopefully this finally helps. If not i guess i can't help you > anymore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
