public virtual void Update(T entity)
        {
            if (IsStatelessSession)
            {
                if (!StatelessSession.IsOpen)
                {
                    throw new HibernateException("The stateless NHibernate session must be open before an entity can be updated.");
                }
                if (StatelessSession.Transaction == null)
                {
                    throw new HibernateException("Updates must be done within an NHibernate transaction.");
                }

                StatelessSession.BeginTransaction();
                StatelessSession.Update(entity);
                StatelessSession.Transaction.Commit();
            }
            else
            {
                if (!Session.IsOpen)
                {
                    throw new HibernateException("NHibernate session must be open before an entity can be updated.");
                }
                if (Session.Transaction == null)
                {
                    throw new HibernateException("Updates must be done within an NHibernate transaction.");
                }

                Session.BeginTransaction();
                Session.Update(entity);
                Session.Transaction.Commit();
            }
        }