Spring Transaction Management Transaction "Go"

Source: Internet
Author: User

Spring provides a number of built-in transaction manager implementations (source Link: https://www.cnblogs.com/qiqiweige/p/5000086.html):

  • Datasourcetransactionmanager : located in the Org.springframework.jdbc.datasource package, the data source transaction Manager provides management of single javax.sql.DataSource transactions for the spring JDBC Abstract framework, Transaction management of Ibatis or mybatis framework;
  • Jdotransactionmanager : in the ORG.SPRINGFRAMEWORK.ORM.JDO package, provides transaction management for a single javax.jdo.PersistenceManagerFactory transaction management, for integration with the JDO framework;
  • Jpatransactionmanager : in the ORG.SPRINGFRAMEWORK.ORM.JPA package, provides support for a single javax.persistence.EntityManagerFactory transaction, for integrating the JPA implementation framework when transaction management;
  • Hibernatetransactionmanager : Located in the Org.springframework.orm.hibernate3 package, provides transaction management support for a single org.hibernate.SessionFactory transaction when integrating the Hibernate framework; the transaction manager only supports Hibernate3 + version, and the spring3.0+ version only supports hibernate 3.2+ version;
  • Jtatransactionmanager : 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 : in the ORG.SPRINGFRAMEWORK.TRANSACTION.JTA package, Spring provides an adapter to the Oc4j10.1.3+ Application Server Transaction manager, which is used to support the advanced transactions provided by the application server;
  • Websphereuowtransactionmanager : in the ORG.SPRINGFRAMEWORK.TRANSACTION.JTA package, Spring provides an adapter to the WebSphere 6.0+ Application Server Transaction manager that is used to support the advanced transactions provided by the application server ;
  • Weblogicjtatransactionmanager : in the ORG.SPRINGFRAMEWORK.TRANSACTION.JTA package, Spring provides an adapter to the WebLogic 8.1+ Application Server Transaction manager, which is used to support the advanced transactions provided by the application server.

Use Datasourcetransactionmanager as an example to manage transactions for the Ibatis or MyBatis framework

Configure in Applicationcontext.xml:

<!--transaction manager -    <BeanID= "Txmanager"class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager">        < Propertyname= "DataSource"ref= "DataSource" />    </Bean>    <!--Configuring Transaction Attributes -    <Tx:adviceID= "Txadvice"Transaction-manager= "Txmanager">        <tx:attributes>            <Tx:methodname= "add*"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "delete*"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "update*"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "save*"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "create*"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "Getexpressbuss"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname= "Getinvoiceinfo"Propagation= "REQUIRED"Isolation= "DEFAULT"rollback-for= "Exception" />            <Tx:methodname="*"read-only= "true" />        </tx:attributes>    </Tx:advice>    <!--configuring which classes of methods require transaction management -    <Aop:config>        <Aop:pointcutID= "Allservicemethod"expression= "Execution (* com.qiqi.web.service). *.*(..)) || Execution (* test.service). *.*(..))" />        <Aop:advisorAdvice-ref= "Txadvice"Pointcut-ref= "Allservicemethod" />    </Aop:config>

Different transaction propagation characteristics can be configured according to different modules

Spring Transaction Management Transaction "Go"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.