O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

NHibernate session versus database session

When we are talking of a database session in the context of ADO.NET, we are actually thinking of an open connection to a database through which we can execute various commands, such as retrieve or manipulate data. Such a session lasts as long as the corresponding ADO.NET connection is open. In code, this would look similar to the following code snippet:

using (var connection = new SqlConnection("..."))
{
  connection.Open();

  //... write to or read from DB

  connection.Close();
}

In NHibernate, a session has a slightly different meaning. We can still think of a NHibernate session being an abstract or virtual conduit to the database. However, this time, there is no need for a physical connection to the database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required