public synchronized T execute()
    {
        try
        {
            session = HibernateSessionFactory.getSession();
            
            T returnValue = null;
            
            if ( session != null )
            {
                session.setFlushMode(FlushMode.MANUAL);
                
                createTransaction = !session.getTransaction().isActive();
                
                if ( createTransaction )
                    transaction = session.beginTransaction();
                
                returnValue = run();
                
                if ( createTransaction )
                {
                    if ( transaction != null )
                        transaction.commit();
                }
                
                session.flush();
            }
            
            return returnValue;
        }
        catch ( RuntimeException ex )
        {
            if ( createTransaction )
            {
                try
                {
                    if ( transaction != null ) 
                        transaction.rollback();
                }
                catch ( Exception exx )
                {
                    // WOPS!
                }
            }
            
            throw ex;
        }
        finally
        {
            session = null;
            transaction = null;
        }
    }