public static void doTxWork( Work work ) {
    	// Non-managed environment idiom
    	Session sess = getSessionFactory().openSession();
    	Transaction tx = null;
    	try {
    	    tx = sess.beginTransaction();

    	    // do some work
    	    work.work(sess);

    	    tx.commit();
    	}
    	catch (RuntimeException e) {
    	    if (tx != null) { 
    	    	tx.rollback();
    	    }
    	    logger.error("Caught an exception doing work", e);
    	    throw e; 
    	}
    	finally {
    	    sess.close();
    	}
    }