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 for the 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, it 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 : located in the org.springframework.transaction.jta package, provides support for distributed transaction management, and delegates transaction management to the Java EE application server transaction manager;

  • OC4JjtaTransactionManager : located in the org.springframework.transaction.jta package, an adapter provided by Spring to the OC4J10.1.3+ application server transaction manager, this adapter is used to support advanced transactions provided by the application server;
  • WebSphereUowTransactionManager : located in the org.springframework.transaction.jta package, the adapter provided by Spring to the WebSphere 6.0+ application server transaction manager, this adapter is used to support the advanced transaction provided by the application server;
  • WebLogicJtaTransactionManager : Located in the org.springframework.transaction.jta package, Spring provides an adapter for the WebLogic 8.1+ application server transaction manager. This adapter is used to support advanced transactions provided by the application server.

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=326992925&siteId=291194637