From 4e39f3b220e5ec3924ea9b29efe3587e85479dde Mon Sep 17 00:00:00 2001 From: Hailton de Castro Date: Tue, 29 Sep 2015 19:46:34 -0300 Subject: [PATCH] The connection was not being effectively closed due to 'NHibernate.ISession.Disconnect ()' contract: // // Summary: // Disconnect the ISession from the current ADO.NET connection. // // Returns: // The connection provided by the application or null // // Remarks: // If the connection was obtained by Hibernate, close it or return it to the // connection pool. Otherwise return it to the application. This is used by // applications which require long transactions. --- .../NHibernate/Support/SessionPerConversationScope.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Spring/Spring.Web.Conversation.NHibernate3/Data/NHibernate/Support/SessionPerConversationScope.cs b/src/Spring/Spring.Web.Conversation.NHibernate3/Data/NHibernate/Support/SessionPerConversationScope.cs index 0baa2cdf..24431f33 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate3/Data/NHibernate/Support/SessionPerConversationScope.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate3/Data/NHibernate/Support/SessionPerConversationScope.cs @@ -435,9 +435,13 @@ namespace Spring.Data.NHibernate.Support conversation.RootSessionPerConversation = null; } else - { - if (tmpSession.IsConnected) - tmpSession.Disconnect(); + { + if (tmpSession.IsConnected) + { + IDbConnection conn = tmpSession.Disconnect(); + if (conn != null && conn.State == ConnectionState.Open) + conn.Close(); + } } RemoveSession(tmpSession); }