@Transactional(rollbackFor = Exception.class) 手动回滚
时间: 2023-10-17 08:25:23 浏览: 101
@Transcational(rollbackFor = Exception.class)是一个用于在方法执行过程中手动回滚事务的注解。当方法中出现异常时,会根据该注解的设置触发事务回滚操作。在引用中的示例代码中,通过调用TransactionAspectSupport.currentTransactionStatus().setRollbackOnly()方法,可以手动将当前事务标记为回滚状态。这样,在方法执行完成后,事务管理器会根据事务的回滚状态进行相应的处理,将事务回滚至之前的状态。所以,在引用中的代码示例中,return语句可以正常执行,但事务会被回滚。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [@Transactional 注解,异常出发回滚,手动回滚。](https://blog.csdn.net/zka_yyds/article/details/130319476)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [@Transactional 注解的方法内手动回滚事务](https://blog.csdn.net/weixin_44665047/article/details/126964222)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文