private <T> T runInTran(Callable<T> arg0) {
EntityTransaction tx = this.em.getTransaction();
try {
tx.begin();
T o = arg0.call();
tx.commit();
callListeners(TransactionStatus.COMMITTED);
return o;
} catch (Exception e) {
tx.rollback();
callListeners(TransactionStatus.ROLLED_BACK);
if(e instanceof ScopedWorkException) {
throw (ScopedWorkException) e;
}
throw new ScopedWorkException("The work failed", e, getCurrentContext());
} finally {
this.txActive.compareAndSet(true, false);
this.context.clear();
this.em.clear();
}
}
TestTransactionControl.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:osc-core
作者:
评论列表
文章目录