Hello forum, I'm developing a WinForm project with C#.NET and I'm using NHibernate. I've developed my project, but I want to improve it using lazy issue. My question is about session manement.
     When I get a Entity I execute this template code:
		
Code:
public Model.Ubicacio getEntity (System.Int32 id) 
      {
         NHibernate.ISession session = this.session_factory.OpenSession();
         NHibernate.ITransaction tx = session.BeginTransaction();
         Model.Entity entity = null;
         try
         {
            entity = (Model.Entity)session.Get(typeof(Model.Entity), id);
         }
         catch (System.Exception ex)
         {
            tx.Rollback();
         }
         finally
         {
            session.Close();
         }
         return ubicacio;
      }
However, I'm retrieving collection with lazy mode, and I can't close the session -->		
Code:
public Model.Ubicacio getEntity (System.Int32 id) 
      {
         NHibernate.ISession session = this.session_factory.OpenSession();
         NHibernate.ITransaction tx = session.BeginTransaction();
         Model.Entity entity = null;
         try
         {
            entity = (Model.Entity)session.Get(typeof(Model.Entity), id);
         }
         catch (System.Exception ex)
         {
            tx.Rollback();
         }
         finally
         {
            //session.Close();
         }
         return ubicacio;
      }
But I think that this isn't the correct solution. How would you design this? I've read about session manegament, but I find anything.
Concrete questions:
     Does Open session means open a database connection?
     While a session is openned implies a database connection is openned?
     What's a transaction? Is it a database connection?
Thanks for all.