spring中事物处理的类

在spring 一段事物的配置中 如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    ">

 <!-- ①:对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 -->
 <context:component-scan base-package="com.zte.adc" />
 <bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName">
   <value>${jdbc.class}</value>
  </property>
  <property name="url">
   <value>${jdbc.url}</value>
  </property>
  <property name="username">
   <value>${jdbc.uid}</value>
  </property>
  <property name="password">
   <value>${jdbc.pwd}</value>
  </property>
 </bean>
 <bean id="propertyConfigurer"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>classpath:reportConfig.properties</value>
   </list>
  </property>
 </bean>

 <!-- 事务管理类
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref bean="sessionFactory"/>
  </property>
 </bean>
 -->
 <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
 </bean>
 <!-- 定义事务管理的通知 -->
 <tx:advice id="txadvice" transaction-manager="transactionManager">
  <!-- 定义业务方法的事物管理特性 -->
  <tx:attributes>
   <tx:method name="qry*" propagation="REQUIRED" read-only="true"></tx:method>
   <tx:method name="*" propagation="REQUIRED" rollback-for="Exception"></tx:method>
  </tx:attributes>
 </tx:advice>

 <!-- 定义AOP配置:切点 -->
 <aop:config>
  <aop:pointcut id="tranaop"
   expression="execution(* com.zte.adc.report.service.*.*(..))" />
  <aop:advisor advice-ref="txadvice" pointcut-ref="tranaop" />
 </aop:config>
</beans>

org.springframework.orm.hibernate3.HibernateTransactionManager

是用于管理 hibernate 事物的类

org.springframework.jdbc.datasource.DataSourceTransactionManager

是用于管理 jdbc事物的类

用于jdo

org.springframework.orm.jdo.JdoTransactionManager

用于 jms

org.springframework.jms.connection.JmsTransactionManager

用于jpa

org.springframework.orm.jpa.JpaTransactionManager

用于jta

org.springframework.transaction.jta.JtaTransactionManager

比如还有 toplink weblogic whspere等的事物处理

原文地址:https://www.cnblogs.com/liaomin416100569/p/9331872.html