Search code examples
javaspringannotations

@Transactional(propagation=Propagation.REQUIRED)


if some one can explain what this annotation do and when exactly we use it :

@Transactional(propagation=Propagation.REQUIRED)

Thanks


Solution

  • When the propagation setting is PROPAGATION_REQUIRED, a logical transaction scope is created for each method upon which the setting is applied. Each such logical transaction scope can determine rollback-only status individually, with an outer transaction scope being logically independent from the inner transaction scope. Of course, in case of standard PROPAGATION_REQUIRED behavior, all these scopes will be mapped to the same physical transaction. So a rollback-only marker set in the inner transaction scope does affect the outer transaction's chance to actually commit (as you would expect it to).

    enter image description here

    http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/transaction.html