Reputation: 1747
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 are all transactionable by themselves.
Thanks
Upvotes: 1
Views: 1732
Reputation: 2365
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.
Upvotes: 2
Reputation: 13473
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.
Upvotes: 0