Example #1
0
        public static void Exec(IHibernateOper hibernateOper, OnSession onSession)
        {
            ISession s = null;
            ITransaction trans = null;
            try
            {
                s = hibernateOper.GetCurrentSession();
                trans = s.BeginTransaction();

                onSession(s);
                
                trans.Commit();
            }
            catch (Exception e)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw e;
            }
        }
Example #2
0
        public static void Exec(IHibernateOper hibernateOper, OnSession onSession)
        {
            ISession     s     = null;
            ITransaction trans = null;

            try
            {
                s     = hibernateOper.GetCurrentSession();
                trans = s.BeginTransaction();

                onSession(s);

                trans.Commit();
            }
            catch (Exception e)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw e;
            }
        }
Example #3
0
        public string Add(T t, OnSession onSession)
        {
            string       retVal = "";
            ISession     s      = null;
            ITransaction trans  = null;

            try
            {
                s     = hibernateOper.GetCurrentSession();
                trans = s.BeginTransaction();

                if (onSession != null)
                {
                    onSession(this, s);
                }

                s.Save(t);

                trans.Commit();

                retVal = t.Id.ToString();
            }
            catch (Exception e)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw e;
            }
            finally
            {
                //                hibernateOper.Close(s);
            }

            return(retVal);
        }