I'm using bean1 with @AfterReturning to make a proxy for a existing bean2 that implements an transactional processing, Bean2 is using @Transactional. The problem is the bean1 proxy method with @AfterReturning is running within a transaction that target bean1 and I would like to execute proxy method outside the target bean1 transaction.
I already searched but did not find how to do this. Anyone know how to do it?
This is bean2 that implements a transactional processing:
This is bean1 used to add advice bean2
The problem is that the bean1 used to add advice to bean2 is running within the transaction bean2.finalizar(). What I need is the bean1 execute with no transactional context. How to do this?
Very strange because I thought the advice would not enter into the transaction bean2.finalizar().
i appreciate any help!
Propagation.NOT_SUPPORTED not work!
Actually it suspends all transactions which are called inside the bean advice.
Only option left to me is to make a GOF Decorator manually. I test and it works correctly .. but it is very bad to do manual ...
Once again try ordering your aspects. You want the after returning aspect of the @Transactional to complete before yours. If you read the link I gave above, the higher precedence will run first going in and last going out. Since @Transactional runs with Ordered.LOWEST_PRECEDENCE by default you could up that value a little by providing it in the @EnableTransactionMnaagent parameters or alternatively on the <tx:annotation-driven/> tag if you are using XML. Then provide an @Order annotation defining a lower precedence to your aspect than what you have defined on the transaction stuff. Note the @Order tag only has an effect if you are using Springs proxy based AOP of you are not using that you need to take a slightly different approach. Have a look at the link below in that case.