Differences between requires_new and nested propagation in Spring transactions

前端 未结 3 1276
-上瘾入骨i
-上瘾入骨i 2020-12-07 14:33

I can\'t understand the behavior difference between the PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED propagation policies. It seems to me that i

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 14:49

    PROPAGATION_REQUIRES_NEW : uses a completely independent transaction for each affected transaction scope. In that case, the underlying physical transactions are different and hence can commit or roll back independently, with an outer transaction not affected by an inner transaction's rollback status.

    PROPAGATION_NESTED : uses a single physical transaction with multiple savepoints that it can roll back to. Such partial rollbacks allow an inner transaction scope to trigger a rollback for its scope, with the outer transaction being able to continue the physical transaction despite some operations having been rolled back. This setting is typically mapped onto JDBC savepoints, so will only work with JDBC resource transactions.

    check spring documentation

提交回复
热议问题