Recently in the SSM framework of the project need to use the implementation of independent transactions, looking for half a day, collected the following theoretical knowledge to prepare for the implementation. Transaction manager for DataSource
(1) Spring specifies 7 types of transaction propagation behavior in the transactiondefinition interface, beginning with propagation,
1:required If there is no transaction, a new transaction is created, and if a transaction already exists, it is added to the transaction. This is the most common choice.
2:supports supports the current transaction, if none is performed in a non-transactional manner
3:mandatory uses the current transaction and throws an exception if none is present
4:requires_new Create a new transaction and suspend the current transaction, you need to use Jtatransactionmanager as the transaction manager (independent transaction with this)
5:not_supported runs in a non-transactional manner, suspends the current transaction and requires the use of Jtatransactionmanager as the transaction manager
6:never runs in a non-transactional manner and throws an exception if there is a transaction
7:nested If an active transaction exists, it is run in a nested transaction. If no current transaction is similar to 1required, Datasourcetransactionmanager uses savepoint support Propagation_ Nested requires JDBC 3.0 or more drivers and more than 1.4 JDK version support, the rollback of the outer transaction can cause the rollback of the inner transaction. The exception of the inner transaction does not cause the rollback of the outer transaction
(2) 5 Different transaction isolation levels are defined in the TransactionManager transaction manager isolution start
1:default using the isolation level of the database by default
2:read_uncommitted allows other transactions to see uncommitted data for the current transaction, with dirty reads, non-repeatable degrees, and Phantom reads
3:read_committed ensure that the current transaction modified data submitted after the other transaction toxin, no dirty read, there will be repeatability and Phantom read general use this can
4:repeatable_read may appear as Phantom read
5:serializable transactions are processed for sequential execution, consuming the most resources
(3) Built-in Transaction manager implementation
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 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.
Spring Independent transaction Analysis