问题描述
如果我有事务方法 A,B,C 和 A 调用 B,C ;然后,C 抛出 A 内部没有捕获的异常.
If I have the transactionable methods A,B,C and A calls B,C ; then, C throws exception that is not caught inside A.
我的问题是 B 是否会回滚?
My question is if B will be rolled back or not?
请注意,嵌套事务默认是禁用的,所以 A、B、C 都是可以自己事务的.
Please note that nested transactions are disabled by default so A, B, C are all transactionable by themselves.
谢谢
推荐答案
请注意,Spring 默认情况下仅在 RuntimeException(或子类)被抛出到事务边界之外时(即当异常未被您的交易方法).
Note that Spring by default only rolls back transactions when a RuntimeException (or a subclass) is thrown outside the transaction boundaries (i.e. when the exception is not caught by your transactional method).
除非您明确指定,否则已检查的异常不会导致 Spring 将事务标记为回滚.
A checked exception will NOT cause Spring to mark the transaction for rollback unless you specify it explicitly.
这篇关于关于 Spring 嵌套事务的简短问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!