隔离级别,isolotion
default 默认为:read_commited
read_uncommited 有脏读,不可重复读,幻像读问题
read_commited 有不可重复读,幻像读问题
repeatable_read 有幻像读问题
serializable 有性能问题
传播行为:propagation behavi
required有事务加入事务,没有则新建事务
required_new新建事务,如果当前存在事务,则挂起当前事务
mandatory有事务加入事务,没有则抛出异常
never以非事务方式处理,有事务则抛出异常
supports有事务加入事务,没有以非事务方式处理
not_supports以非事务方式处理,当前存在事务则挂起当前事务
nested 当前无事务时相当于required
基于TransactionInterceptor 的声明式事务管理
基于 TransactionProxy... 的声明式事务管理
基于 <tx> 命名空间的声明式事务管理
基于 @Transactional 的声明式事务管理
==========基于 TransactionProxy... 的声明式事务管理==========
<beans>
<bean id="bankServiceTarget" class="footmark.spring.core.tx.declare.classic.BankServiceImpl">
<property name="bankDao" ref="bankDao"/>
</bean>
<bean id="bankService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="bankServiceTarget"/>
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="transfer">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>
==========基于TransactionInterceptor 的声明式事务管理==========
<beans>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="transfer">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="bankServiceTarget" class="footmark.spring.core.tx.declare.origin.BankServiceImpl">
<property name="bankDao" ref="bankDao"/>
</bean>
<bean id="bankService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target" ref="bankServiceTarget"/>
<property name="interceptorNames">
<list>
<id ref bean="transactionInterceptor"/>
</list>
</property>
</bean>
</beans>
==========基于 <tx> 命名空间的声明式事务管理==========
<beans>
<bean id="bankService" class="footmark.spring.core.tx.declare.namespace.BankServiceImpl">
<property name="bankDao" ref="bankDao"/>
</bean>
<tx:advice id="bankAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="transfer" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="bankPointcut" expression="execution(* *.transfer(..))"/>
<aop:advisor advice-ref="bankAdvice" pointcut-ref="bankPointcut"/>
</aop:config>
</beans>
<beans>
<bean id="bankService" class="footmark.spring.core.tx.declare.namespace.BankServiceImpl">
<property name="bankDao" ref="bankDao"/>
</bean>
<tx:advice id="bankAdvice" transaction-manager="transactionManager">
<aop:config>
<aop:pointcut id="bankPointcut" expression="execution(**.transfer(..))"/>
<aop:advisor advice-ref="bankAdvice" pointcut-ref="bankPointcut"/>
</aop:config>
</beans>