NHibernate and ADO.NET Connection Pooling?

Nbernate has two "modes Either you open the connection in your application, then it is up to the application to manage it. This "mode" is used when passing a connection to sessionfactory. OpenSession(connection) Or the connection is created by NH.

Then it is closed when the session is closed. This "mode" is used when not passing a connection to 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).

Nbernate has two "modes". Either you open the connection in your application, then it is up to the application to manage it. This "mode" is used when passing a connection to sessionfactory.

OpenSession(connection). Or the connection is created by NH. Then it is closed when the session is closed.

This "mode" is used when not passing a connection to 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).

Thanks for your reply but I think you're wrong with the "second" mode. When the session is disposed the connection stays open. As you can see in the code snipped I posted above (ConnectionManager.Cs) it's not possible to disconnect/reconnect within a transaction scope.

In the link you provided it is also said that you must first commit/abort the transaction before you can disconnect/reconnect again. The connection (IDbConnection) is controlled by the ConnectionManager class as a private member and not by the transaction. – Antineutrino Sep 27 at 12:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions