Hibernate version:
1.0.2.0
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Tests.TestObj, Tests" table="TestObjs">
<id name="m_id" access="field" column="TestObjID">
<generator class="identity" />
</id>
<property name="m_name" access="field" column= "TestObjName"/>
</class>
</hibernate-mapping>
Code:
Code:
<Test()> _
Public Sub CreateATransaction()
Dim session As ISession
Dim trx As ITransaction
Try
Dim sessionFactory As NHibernate.ISessionFactory
Dim config As NHibernate.Cfg.Configuration
config = New NHibernate.Cfg.Configuration
config.AddAssembly("Tests")
sessionFactory = config.BuildSessionFactory()
session = sessionFactory.OpenSession()
trx = session.BeginTransaction
trx.Rollback()
' session.Connection.Close()
session.Close()
sessionFactory.Close()
Assert.IsTrue(trx.WasRolledBack)
Assert.IsFalse(session.IsOpen)
Assert.IsFalse(session.IsConnected)
trx = Nothing
session = Nothing
sessionFactory = Nothing
config = Nothing
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
Name and version of the database you are using:
MS SQL 2005
Hi there,
I don't have any error or something like that in my code, just a question.
When I run the code above everything works just fine. I open a session, a transaction, I rollback the thing close everthing I have to close and go on.
When I now open SQL Server Profiler, I still have an open connection to the database while I clearly told everything to close. If I close the program the connection will terminate but why exactly is that one connection still there and how can I make sure it does close?