spring transaction manager summary

Spring provides a number of built-in transaction manager implementations:

  • DataSourceTransactionManager : located in the org.springframework.jdbc.datasource package, the data source transaction manager, provides transaction management for a single javax.sql.DataSource, which is used for transaction management of the Spring JDBC abstraction framework, iBATIS or MyBatis framework;

    Java code Favorite code
    1. <bean id="txManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
    2. <property name="dataSource" ref="dataSource"/>
    3. </bean>
  • JdoTransactionManager : located in the org.springframework.orm.jdo package, provides transaction management for a single javax.jdo.PersistenceManagerFactory for transaction management when integrating the JDO framework;
    Java code
    1. <bean id="txManager"class="org.springframework.orm.jdo.JdoTransactionManager"> 
    2. <property name="persistenceManagerFactory" ref="persistenceManagerFactory"/>
    3. </bean>
  • JpaTransactionManager : located in the org.springframework.orm.jpa package, provides transaction support for a single javax.persistence.EntityManagerFactory for transaction management when integrating the JPA implementation framework;
    Java code
    1. <bean id="txManager"class="org.springframework.orm.jpa.JpaTransactionManager"> 
    2. <property name="entityManagerFactory" ref="entityManagerFactory"/>
    3. </bean>
    4. <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      ……
      <property name="jpaDialect" ref="jpaDialect"/>
      </bean>
      <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
  • HibernateTransactionManager : located in the org.springframework.orm.hibernate3 package, provides transaction support for a single org.hibernate.SessionFactory for transaction management when integrating the Hibernate framework; this transaction manager only supports Hibernate3+ version, and Spring3.0+ version only supports Support Hibernate 3.2+ version;
    Java code
    1. <bean id="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
    2. <property name="sessionFactory" ref="sessionFactory"/>
    3. </bean>
  • JtaTransactionManager位于org.springframework.transaction.jta包中,提供对分布式事务管理的支持,并将事务管理委托给Java EE应用服务器事务管理器;

  • OC4JjtaTransactionManager位于org.springframework.transaction.jta包中,Spring提供的对OC4J10.1.3+应用服务器事务管理器的适配器,此适配器用于对应用服务器提供的高级事务的支持;
  • WebSphereUowTransactionManager位于org.springframework.transaction.jta包中,Spring提供的对WebSphere 6.0+应用服务器事务管理器的适配器,此适配器用于对应用服务器提供的高级事务的支持;
  • WebLogicJtaTransactionManager位于org.springframework.transaction.jta包中,Spring提供的对WebLogic 8.1+应用服务器事务管理器的适配器,此适配器用于对应用服务器提供的高级事务的支持。

In the follow-up articles, I will add the usage of each TransactionManager, as well as the transaction management frequently used in our research and development process, which methods, and the problems we have when doing cross-transaction management

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326992949&siteId=291194637