java - Spring: How to commit transaction before entering @AfterReturning advice -
i've got transactional service class:
@service @transactional(...) public class myservice() { public void myfunc() { // code } }
also following aspect:
@aspect public class myaspect() { @afterreturning(value = "execution(...") // pointcut matching myfunc()'s signature public void dosomethingaftermyfunc() { // code } }
the problem i'm facing upon entering @afterreturning advice, transaction created execution of myfunc() not yet committed, advice shares same transaction. i've read behavior expected, purposes need opposite - there way commit myfunc()'s transaction before entering advice?
thanks in advance!
this happening because of @transactional
aspect, have 2 aspects in code have set order
explained https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-ataspectj-advice-ordering
in code set order of own aspect myaspect
following:
@aspect @order(1) public class myaspect() { //your code here }
by specifying order 1 , since rule that:
on way out joinpoint, advice highest order value gets executed first.
the @transactional
aspect executed prior yours myfunc
commited , dosomethingaftermyfunc
executed.
Comments
Post a Comment