I’m getting the following error on our production web server:
NHibernate.LazyInitializationException
:
Initializing[Domain.Entities.AudienceTypes.Region#4]-failed to lazily initialize a
collection of role: Domain.Entities.AudienceTypes.Region.PeerGroups,
no session or session was closed
which isn’t good. The only way to get the application working again is to reset IIS, which isn’t really an option. What does this mean? How can I prevent it?
Relationships by default are lazy. That means that the SQL query to load the relationship is executed only when you access the property that holds the relationship.
The problem is that if you access a lazy property, that has never been called before, with the session closed then you get that error.
You have to solutions: