The following applies since at least NH 2.0: The fact that the ISession releases the connection is not the cause of your problem. If NHibernate is managing the database connections by itself, the ISession will release the underlying ado.net connection whenever there is no active transaction. This is to avoid holding connections that isn't used. A connection will be retrieved again when needed.
Your real problem is hidden in your code somewhere. /Oskar 2010/9/28 MattO <[email protected]>: > I use session per request, therefore the session should stay open for > the duration of my ASP .NET request, but it does not seem to be doing > that. > > Instead nHibernate seems to be closing the connection and I'm not sure > why. > > Here is the important parts of the log: > > 2010-09-28 08:47:20,536 [12] INFO NHibernate.Loader.Loader [(null)] - > SELECT COUNT(*) AS Count FROM FormDetail INNER JOIN Items ON > FormDetail.RecordID = Items.RecordID WHERE (Items.QTypeID = @p0) and > form...@p1 > 2010-09-28 08:47:20,551 [12] DEBUG > NHibernate.Connection.DriverConnectionProvider [(null)] - Obtaining > IDbConnection from Driver > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.AbstractBatcher > [(null)] - ExecuteReader took 3 ms > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.AbstractBatcher > [(null)] - Opened IDataReader, open IDataReaders: 1 > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Loader.Loader [(null)] - > processing result set > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Loader.Loader [(null)] - > result set row: 0 > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Loader.Loader [(null)] - > result row: > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Type.Int32Type [(null)] > - returning '0' as column: Count > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Loader.Loader [(null)] - > done processing result set (1 rows) > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Driver.NHybridDataReader > [(null)] - running NHybridDataReader.Dispose() > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.AbstractBatcher > [(null)] - Closed IDataReader, open IDataReaders :0 > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.AbstractBatcher > [(null)] - DataReader was closed after 3 ms > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.AbstractBatcher > [(null)] - Closed IDbCommand, open IDbCommands: 0 > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.ConnectionManager > [(null)] - aggressively releasing database connection > 2010-09-28 08:47:20,551 [12] DEBUG > NHibernate.Connection.ConnectionProvider [(null)] - Closing connection > 2010-09-28 08:47:20,551 [12] DEBUG > NHibernate.Engine.StatefulPersistenceContext [(null)] - initializing > non-lazy collections > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.ConnectionManager > [(null)] - after autocommit > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.Impl.SessionImpl > [(null)] - transaction completion > 2010-09-28 08:47:20,551 [12] DEBUG NHibernate.AdoNet.ConnectionManager > [(null)] - aggressively releasing database connection > 2010-09-28 08:47:22,829 [12] ERROR > NHibernate.LazyInitializationException [(null)] - > Initializing[ItemBankCoreNH.BusinessObjects.Form#BS]-failed to lazily > initialize a collection of role: > ItemBankCoreNH.BusinessObjects.Form.ExamTypes, no session or session > was closed > NHibernate.LazyInitializationException: > Initializing[ItemBankCoreNH.BusinessObjects.Form#BS]-failed to lazily > initialize a collection of role: > ItemBankCoreNH.BusinessObjects.Form.ExamTypes, no session or session > was closed > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > 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. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. 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.
