Hello all,

I have the following situation, I have a Group with multiple Items. I want 
to query the groups and then fetch the items using an outer join.

This results in the following LINQ query:

[code]
var groups = from x in Session.Query<Groups>().Fetch(y => y.Items)

select x;

[/code]

This works fine, but now I want to use Query and 2nd level caching of 
NHibernate to cache this... So I add .Cacheable() after the Fetch() call.
The first query will hit the database (as expected), but subsequent query's 
hit the cache and since the Session is closed in the View (ASP.NET MVC 3 
application) I get a LazyInitializationException because the 'Items' 
collection can not be loaded.

What causes this behaviour? Is this a bug? Or am I not supposed to do this 
and expect the query cache to work?

The cache is enabled and working for other queries, and the cache property 
is set. I've verified all these things.

Kind regards,

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/bSl_EyFdIX8J.
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