On 7 nov, 16:36, "Fabio Maulo" <
fabioma...@gmail.com> wrote:
> 2008/11/7 FrederikGheysels <
frederik.gheys...@pandora.be>
>
> > I expect that the Session is disconnected after the Commit
> > Transaction, but it is not. The Session is still connected.
>
> Trust us ;)
> and don't worry about it.
>
> --
> Fabio Maulo
Please allow me to be a bit critical :)
When Ayende says that NH maintains the abstraction that the session
always has an open connection, then this also implies that the
IsConnected property of the ISession should always return true.
(Then, I wonder: what's the use of this property ) ?
I've also done a little test:
using( UnitOfWork uow =
UnitOfWorkFactory.Instance.CreateUnitOfWork () )
{
ISession s = uow.Session;
Assert.IsTrue (s.IsOpen, "Session is expected to be
open");
Assert.IsTrue (s.IsConnected, "Session is expected to
be connected");
Assert.AreEqual
(s.SessionFactory.Settings.ConnectionReleaseMode,
ConnectionReleaseMode.AfterTransaction,
"ConnectionReleaseMode is expected to
be AfterTransaction");
Assert.AreEqual (s.FlushMode, FlushMode.Auto,
"FlushMode must be Auto");
ITransaction tx = s.BeginTransaction
();
tx.Commit ();
Assert.IsFalse (s.IsConnected, "Session should be
disconnected");
}
This test fails on the last Assert.
I've also checked the number of connections using the SQL Server
sp_who SP.
From the results of this SP, I learn that the connection to my DB is
kept open when the Transaction has been committed ...