Reputation: 2672
ASP.NET site.
Constantly got the exception
LazyInitializationException: ... -Could not initialize proxy - no Session.
NHibernate.LazyInitializationException: Initializing[MyProj.MyClass#XXX]-Could not initialize proxy - no Session.
at NHibernate.Proxy.AbstractLazyInitializer.Initialize()
at NHibernate.Proxy.DefaultLazyInitializer.Intercept(InvocationInfo info)
at MyClassProxy.get_MyProjerty()
Upvotes: 0
Views: 874
Reputation: 2672
We've cached NHibernate entities but this is a dangerous idea to cache ORM objects.
We could do the following
Keep in mind that somebody my enable or disable lazy loading and you'll get in troubles for a long time. Or someone may manage the session lifetime in an unexpected way. Or the session could become corrupted if a DB connection became interrupted.
I don't know yet what guys will choose to fix this issue.
Upvotes: 1