spring事务无异常回滚 [spring rollback without exception]

在使用spring的时候通常我们可以通过抛出异常的方式完成回滚,当然是runtime的异常,但是在一些复杂业务逻辑1中,往往我们需要service返回的不只是异常信息,很可能是异常的code,甚至一些其他的信息。
这个时候我们就不能抛出异常,那么这个时候可以通过一下方法完成数据库的回滚:

TransactionInterceptor.CurrentTransactionStatus.RollbackOnly = true
或者
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
这个应该是不同版本的使用方式。

参考地址:
http://forum.springframework.net/archive/index.php/t-4264.html

你可能感兴趣的:(spring,html,PHP,.net)