I use NHibernate with mySQL 5, and I'm a little unsure if NHibernate really closes the connection to mySQL.
This is the code I use to store the Player object in the database:
using (ISession session = SessionFactory.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(player); transaction.Commit(); } }
After running this piece of code, I select the current number of connections from the mySQL server using
show status like 'Conn%' ;
and the value increases each time by 1!
Thus, inserting a player 10 times (= starting the program 10 times) increases the number of connections by 10. But the NHibernate session.IsClosed property of the session is false.
Do I need to do something to free up NHibernate resources and close the connection? Are connections / timeout connected?
It would be great if someone could give me a hint.
source share