Today continue to study spring business, found that many articles on the web are very similar to the reprint is not much value, it is more necessary to take this topic into the deep, first extracts those who are useful to their views, and later combined with the source code for a comprehensive collation.
Spring provides a number of built-in transaction manager implementations that are commonly used in the following ways:
- Datasourcetransactionmanager: In the Org.springframework.jdbc.datasource package, the data source transaction manager, which provides management for a single javax.sql.DataSource transaction, for spring The transaction management of JDBC Abstract framework and ibatis framework;
- Hibernatetransactionmanager: Located in the Org.springframework.orm.hibernate3 or HIBERNATE4 package, provides support for a single org.hibernate.SessionFactory transaction for integration The transaction management of Hibernate framework, the transaction manager only supports hibernate3+ version, and 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;
- Programmatic transaction management based on Transactiondefinition, Platformtransactionmanager, and Transactionstatus is the most primitive way Spring provides, and we don't usually write that But understanding this approach has a great effect on understanding the nature of Spring's transaction management.
- Transactiontemplate-based, programmatic transaction management is the encapsulation of the previous approach, making coding simpler and clearer.
- Transactioninterceptor-based declarative transactions are the basis of spring declarative transactions and are not generally recommended, but as before, understanding this approach has a significant effect on understanding Spring declarative transactions.
- Transactionproxyfactorybean-based declarative transactions are an improved version of the Chinese-style, simplified configuration file writing, which is a declarative transaction management approach recommended by spring in the early days, but is not recommended in Spring 2.0.
- Declarative transaction management based on <tx> and <aop> namespaces is the current recommended approach, with the greatest feature of combining Spring AOP with the strong support of pointcut expressions to make management transactions more flexible.
- The @Transactional-based approach simplifies declarative transaction management to the extreme. Developers simply add a line to the configuration file to enable the configuration of the related post-processing Bean, and then use the @Transactional to specify transaction rules on methods or classes that need to implement transaction management to achieve transaction management, and do not have the same functionality in other ways.
Excerpt from: http://www.ibm.com/developerworks/cn/education/opensource/os-cn-spring-trans/
2015 24th Tuesday Spring Business 2