Transactional method calling another method without @Transactional anotation?

When you call a method without Transactional with in 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 within the same instance then the called methods transactional behavior will not have any impact on the transaction. But if you call a method will a transaction definition from another method with transaction definition and is in different instance then the code in the called method will follow the transaction definitions given in the called method 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 creation of the transactions.

The AOP proxy will be active only if the methods with in the instance are called from out side the instance.

When you call a method without @Transactional with in 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 within the same instance then the called methods transactional behavior will not have any impact on the transaction.

But if you call a method will a transaction definition from another method with transaction definition and is in different instance then the code in the called method will follow the transaction definitions given in the called method. 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 creation of the transactions.

The AOP proxy will be active only if the methods with in the instance are called from out side the instance.

– goe Jun 3 at 3:18 Yes. It is the default behavior. – Arun P Johny Jun 3 at 3:20 @Arun There is one more dimension to that which is transaction propagation attribute.

In @Transactional you can specify propagation attribute that is enumeration value of type @Propagation. – Tomasz Blachowicz Jun 3 at 12:43 @Tomasz Yes. But it should also be mentioned that changing transaction propagation on a method that is called from another @Transactional method will have no effect.

– Filip Jun 3 at 17:13 @Tomasz, That was what I meant by saying will follow the transaction definitions given in the called method. But if the call is comes from the same object instance it will not have any effect since the call will not propagate through the aop proxies which are responsible for the transaction maintenance. – Arun P Johny Jun 37 at 6:29.

Transactional marks the transaction boundary (begin/end) but the transaction itself is bound to the thread. Once a transaction starts it propagates across method calls until the original method returns and the transaction commits/rolls back. If another method is called that has a @Transactional annotation then the propagation depends on the propagation attribute of that annotation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions