It seems that the option you're talking about (called in hibernate: 'connection.release_mode' = 'after_statement') is not supported by nHibernate. A piece of code from nhibernate source:
private static ConnectionReleaseMode ParseConnectionReleaseMode(string name) { switch (name) { case "after_statement": throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate"); case "after_transaction": return ConnectionReleaseMode.AfterTransaction; case "on_close": return ConnectionReleaseMode.OnClose; default: throw new HibernateException("could not determine appropriate connection release mode [" + name + "]"); } } On Feb 18, 6:51 pm, taoufik <taoufik.zam...@fortisinvestments.com> wrote: > Interesting to know that the session does a db connection management > itself. Is there a way to demonstrate when the session will > automatically disconnect if not in a transaction? > > On Feb 18, 5:26 pm, Oskar Berggren <oskar.bergg...@gmail.com> wrote: > > > I think this can be resolved by not disconnecting manually. Unless > > you're in a transaction, the ISession will automatically release the > > DbConnection back to the pool anyway. > > > /Oskar > > > 2010/2/18 taoufik <taoufik.zam...@fortisinvestments.com>: > > > > We use one (read-only) session which we disconnect as soon as we > > > retrieve the data from the database. The data retrieved, often has > > > lazy-loaded properties which are not initialized yet. > > > > When we try to access the properties, the following exception gets > > > thrown: > > > > NHibernate.LazyInitializationException > > > > Initializing[NHibernateTest.AppUser#16]-failed to lazily initialize a > > > collection of role: NHibernateTest.AppUser.Permissions, session is > > > disconnected > > > > Is there a way (add-on/interceptor) to automatically detect that the > > > application is trying to access an uninitialized property, so that the > > > interceptor can quickly open the connection and close it after the > > > unit of work? > > > > Fetching everything at once would nullify the usage of laziness. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "nhusers" group. > > > To post to this group, send email to nhus...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > nhusers+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.