It seems that NHibernate does not pool ADO.NET database connections. Connections are only closed when the transaction is committed or rolled back. A review of the source code sh
NHibernate has two "modes".
sessionfactory.OpenSession(connection)
.sessionfactory.OpenSession()
There is some support for TransactionScope
. It is most probably using the first "mode". Probably the connection is not hold by NH, but by the transaction scope. I don't know exactly, I don't use environment transactions.
NH is using the ADO.NET connection pool by the way.
You can also disconnect the session using ISession.Disconnect()
and reconnect using ISession.Reconnect()
.
In the documentation you find:
The method ISession.Disconnect() will disconnect the session from the ADO.NET connection and return the connection to the pool (unless you provided the connection).