Transaction management in Spring

Source: Internet
Author: User

"Introduction to Transactions"

1. Transaction management is an essential technology in enterprise-level application development. used to ensure the integrity and consistency of data .

2. A transaction is a series of actions that are treated as a separate unit of work. These actions are either complete or all of them do not work.

(For example: transfer money, this side turned out 500 yuan, there received 500 yuan, or all completed, or all do not work.) )

3. Four key properties of a transaction (acid)

(1) atomicity (atomicity): A transaction is an atomic operation consisting of a series of actions. The atomicity of the transaction ensures that the action is either complete or all is not working.

(2) Consistency (consistency): Once all the transaction actions are complete, the transaction is committed. Data and resources are in a consistent state that satisfies business rules.

(3) Isolation (isolation): There may be many transactions that process the same data at the same time, so each transaction should be isolated from other transactions to prevent data corruption.

(4) Persistence (durability): Once a transaction is complete no matter what system error occurs, its results should not be affected. Typically, the result of a transaction is written to persistent memory.

"Transaction management in Spring"

1. As an enterprise application framework,Spring defines an abstraction layer on top of different transaction management APIs . Instead of having to understand the underlying transaction management API, application developers can use spring's transaction management mechanism.

2.Spring supports both programmatic transaction management and declarative transaction management.

3. Programmatic Transaction management: Embed transaction management code into business methods to control the commit and rollback of transactions . When you programmatically manage transactions, you must include additional transaction management code in each transaction operation.

4. Declarative Transaction Management : In most cases, it is better than programmatic transaction management. It separates the transaction management code from the business method and implements the transaction management in a declarative manner . Transaction management, as a crosscutting concern, can be modularized through the AOP approach, andspring supports declarative transaction management through the Spring AOP framework .

"Transaction manager in Spring"

1.Spring abstracts a set of transactional mechanisms from different transaction management APIs. Developers can take advantage of these transactional mechanisms without having to understand the underlying transactional APIs. with these transactional mechanisms, transaction management code can be independent of specific transactional technologies .

The core transaction management abstraction of 2.Spring is interface platform TransactionManager Management encapsulates a set of technology-independent approaches. The transaction manager is required, regardless of which transaction management policy (programmatic or declarative) is used in spring.

"Different implementations of transaction managers in spring"

1.class DataSource TransactionManager: Only one data source needs to be processed in the application and is processed through JDBC.

2.Class JTA TransactionManager: Transaction Management with JTA (Java Transaction API) on the Java EE Application Server.

3.Class Hibernate TransactionManager: Accessing the database with the Hibernate framework

。。。

4. The transaction manager is declared in a normal bean form in a spring IOC container.

Transaction management in Spring

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.