I couldn’t find a definitive answer to this in the docs, and although there seems to be a logical answer, one can’t be sure. The scenario is this – you have a xml-based transaction definition, like:
<tx:advice id="txAdvice" transaction-manager="jpaTransactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
Which advises all service methods. But then you have @Transactional on a concrete class/method, where you want to override the propagation attribute.
It is clear that @Transactional at method-level overrides the same one at class-level, but does it override the <tx:advice> (and actually, the <aop:pointcut>)?
I hope two interceptors won’t be created on the same class, (and whichever happens to be first will start the transaction)
Thanks to skaffman for his effort. Finally I think I got the behaviour:
<aop:advisor>and@Transactional(together with<tx:annotation-driven>) create aTransactionInterceptoraround the target class (the one, whose methods are to be run in transaction).orderattribute overrides the other one. If no order attribute is specified, the order is undefined. But my tests showed that the one defined latest in theapplicationContext.xmltakes precedence, although this might not be the case always:At least this is the behaviour for spring 2.5.6.