Spring has several transaction management, what is the Spring transaction management interface

Source: Internet
Author: User

1,spring has two ways of managing transactions: ① programmatic ② declarative. Programming is more flexible, but the code is large, there are more duplicate code, and declarative transaction management is more flexible and convenient than programming.

The declarative transaction management based on AOP is essentially intercepting the method before and after execution, and then creating and joining the transaction before the method executes, committing the transaction according to execution or rolling back the transaction after executing the target method.

There are two forms of declarative transaction management: The ① configuration file ② add @transaction annotations to the business method and apply the transaction rules to the business logic.

2,spring's transaction management interface has three main: Transactiondefinition, Platform TransactionManager, Transaction Status.

① in spring, transactions are defined by the Transactiondefinition interface, which contains methods related to transaction properties, Transactiondefinition defines five constants representing isolation levels, constants that represent propagation behavior, In Transactiondefinition, the time-out is expressed as an int value.

The ②platform transactionmanager.getinstance () method returns a transaction status object that returns the transaction The status object may represent a new or already existing transaction (if there is a qualifying transaction in the current call stack).

The ③transaction status interface provides a simple way to control transaction queries and execution.


Another: Whether a transaction needs to be created is controlled by the transactional propagation behavior. Read data does not need or specify a read-only transaction, and the transaction is required to change the transaction management.

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.