AOP Advice Ordering & Declarative Transaction
Hi,
I am using Spring/Hibernate with declarative transaction:
<aop:config>
<aop:advisor id="managerTx" advice-ref="txAdvice"
pointcut="execution(* *..service.*Manager.*(..))" order="2" />
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>
Now I want to add an after-returning advice on a method foo() of one of my Managers. Say,
CustomerManager.foo(..)
foo(..) will do insert one record in DB.
I want to make sure that the transaction has been commited before my advice take control. So I added the following annotations in my advice method
@AfterReturning(execution("* CustomerManager.foo(..)"))
@Order(5)
public void myAdvice(){
.......
}
However, the @Order annotation dos not seem to work. myAdvice() is called when foo() is called. But on exit, it is called before transaction is commited.
My undertsanding is that Spring uses AOP implement transactin management - I just don't know why my Order annotation (value "10") does not work as I expected.
The tx advice order is only "2".
Any idea?
Thanks.
Joe