Spring Transaction 五: 使用基于注解的AOP的事务管理
xml aop事务管理
1. Example
<tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"/> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><tx:method name="get*" read-only="false"/><tx:method name="*"/></tx:attributes> </tx:advice> <aop:config><aop:pointcut id="pointcut" expression="execution(* com.mycompany.service.*.*(..))"/><aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/> </aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><tx:method name="*" isolation="READ_COMMITED" propagation="REQUIRED" timeout="100"/> <tx:method name="get*" readonly=true/></tx:attributes> </tx:advice>