Code example for Callable

Methods: call

0
	} 
 
	public <T> T execute(Callable<T> code) {
		try { 
			if (session.getTransaction().isActive()) {
				return code.call();
			} else { 
				org.hibernate.Transaction tx = session.beginTransaction();
				try { 
					T result = code.call();
					tx.commit();
					return result;
				} finally { 
					if (tx.isActive()) {
						tx.rollback();
					} 
				} 
			} 
		} catch (Exception e) {
			throw new RuntimeException(e);
		}