@FunctionalInterface public interface TxFun
例如通过返回值 Ret 对象来决定事务的提交与回滚:
Tx.setTxFun((inv, conn) -> {
inv.invoke();
// 根据业务层返回值 Ret 对象的状态决定提交与回滚
Object retValue = inv.getReturnValue();
if (retValue instanceof Ret) {
Ret ret = (Ret)retValue;
if (ret.isOk()) {
conn.commit();
} else {
conn.rollback();
}
return ;
}
// 返回其它类型值的情况
conn.commit();
});
| 限定符和类型 | 方法和说明 |
|---|---|
void |
call(com.litongjava.jfinal.aop.AopInvocation inv,
Connection conn) |
void call(com.litongjava.jfinal.aop.AopInvocation inv,
Connection conn)
throws SQLException
SQLExceptionCopyright © 2024. All rights reserved.