/**
* Invokes the method wrapped within a unit of work and a transaction.
*
* @param methodInvocation the method to be invoked within a transaction
* @return the result of the call to the invoked method
* @throws Throwable if an exception occurs during the method invocation, transaction, or unit of
* work
*/
private Object invokeInTransactionAndUnitOfWork(MethodInvocation methodInvocation)
throws Throwable {
boolean unitOfWorkAlreadyStarted = unitOfWork.isActive();
if (!unitOfWorkAlreadyStarted) {
unitOfWork.begin();
}
Throwable originalThrowable = null;
try {
return dslContextProvider.get().transactionResult(() -> {
try {
return methodInvocation.proceed();
} catch (Throwable e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RuntimeException(e);
}
});
} catch (Throwable t) {
originalThrowable = t;
throw t;
} finally {
if (!unitOfWorkAlreadyStarted) {
endUnitOfWork(originalThrowable);
}
}
}
JooqTxnInterceptor.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:beadledom
作者:
评论列表
文章目录