Spring事务管理
1 声明式事务 手动回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
2 同一个事务里面部分回滚
Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
3 异步线程事务在主线程事务提交后执行
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
TransactionSynchronization.super.afterCommit();
//123
}
});
4 lambada事务
transactionTemplate.execute(transactionStatus -> {
//todo 123
return null;
});
参考:1:https://blog.csdn.net/justry_deng/article/details/80828180
2:https://www.cnblogs.com/konglxblog/p/16229175.html
3:https://blog.csdn.net/f641385712/article/details/89602418
浏览 (573)
点赞 (1)
收藏