When you call a method without
@Transactional within a transaction block, the parent transaction will continue to the new method. It will use the same connection from the parent method (with
@Transactional) and any exception caused in the called method (without
@Transactional) will cause the transaction to rollback as configured in the transaction definition.
If you call a method with a
@Transactional annotation from a method with
@Transactional belonging to the same Spring
Bean, then the called methods transactional behavior will not have any impact on the transaction. But if you call a method with a transaction definition from another method with a transaction definition, and they belong to different Spring
Beans, then the code in the called method will follow its own transaction definitions.
You can find more details in the section Declarative transaction management of spring transaction documentation.
Spring declarative transaction model uses AOP proxy, so the AOP proxy is responsible for transactions creation. The AOP proxy will be active only if the called method belong to a different Spring
Bean than the caller one.
Leave an answer