I have a strange behaviour which I can't find any solution for days..
The behaviour I experience is the classic LazyInitializationException
with no session or session was closed
which is usual when there's no contextual session and trying to access lazy loaded properties/collections, but this in not my case because I have:
- Session-per-request session bounded with Spring.NET
OpenSessionInViewModule
- A session opened and bounded to the context (web request)
- Entities with collection as "list" (mapping list collection) with lazy="extra" or with "set" (mapping set collection) (The issue is caused mainly with lazy=extra..)
- It seems that the Count statement for extra cound be done, but accessing the whole collection throws the exception
After investigating the usual issues:
no session opened
the object is not bounded to any session
a call to
Session.Clear
orSession.Evict
was made (so any lazy for the evicted instance will work)the Spring.NET WebSupportModule is not registered
I found no explicit reasons of why this happen.. A strange behaviour is if I profile in
NHprof
, I see the exception in a new session, in other words, the contextual session works correctly, but when the exception is thrown, that exception is visualized in a secondary session.. but NO code open a session, and a single, contextual session is opened..
Anyone knows what other reasons could cause a situation like that? Thanks in advance