Transaction, how spring transaction works

Transaction:

        Definition: A transaction is a unit of concurrency control and a sequence of operations defined by the user. These operations are either done or not done, and they are an inseparable unit of work. Transactions allow SQL Server to bind together a logically related set of operations so that the server maintains data integrity.

       Way: 

       A transaction usually begins with a BEGIN TRANSACTION and ends with a COMMIT or ROLLBACK.

       COMMIT means commit, that is, commit all operations of the transaction. Specifically, all updates to the database in the transaction are written back to the physical database on disk, and the transaction ends normally.
       ROLLBACK means rollback, that is, a certain failure occurs during the operation of the transaction, and the transaction cannot continue. The system undoes all completed operations on the database in the transaction and rolls back to the state where the transaction started.

       Three modes of transaction operation:

       A: Auto-commit transactions

          Each individual statement is a transaction. A COMMIT is implied after each statement.
       B: An explicit transaction
       starts explicitly with BEGIN TRANSACTION and ends with a COMMIT or ROLLBACK.
       C: Implicit transactions
       New transactions are started implicitly when the previous transaction completes, but each transaction still ends explicitly with a COMMIT or ROLLBACK.

 Characteristics of Transactions (ACID Characteristics)

       A: Atomicity
       transaction is the logical unit of work of the database. The operations included in the transaction are either done or not done at all.
       B: Consistency
       The result of transaction execution must be to change the database from one consistent state to another consistent state. Consistency and atomicity are closely related.
       C: Isolation (Isolation)
      The execution of a transaction cannot be interfered with by other transactions.
       D: Durability/Permanence (Durability)
      Once a transaction is committed, its changes to the data in the database should be permanent. Note: A transaction is the basic unit of recovery and concurrency control. Spring transaction principle spring transaction, around the two core PlatformTransactionManager and TransactionStatus spring provides several classes about transaction processing: 
                       

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326775414&siteId=291194637