开发者

short and easy question on spring nested transactions

If I have the transactionable methods A,B,C and A calls B,C ; then, C throws exception that is not caught inside A.

My question is if B will be rolled back or not?

Please note that nested transactions are disabled by default so A, B, C 开发者_Python百科are all transactionable by themselves.

Thanks


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).

A checked exception will NOT cause Spring to mark the transaction for rollback unless you specify it explicitly.


Yes.

If A, B, and C are all @Transactional methods, and A calls B and C, Spring will manage the transactional nature of all three using a single transaction. In other words, the invocation of A, B, and C will in effect share a single transaction. If C throws an exception, the single transaction used by A, B, and C would be rolled back.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜