Seven attributes and five isolation levels of spring things, and seven types of spring things

Source: Internet
Author: User

Seven attributes and five isolation levels of spring things, and seven types of spring things
First, let's talk about the Transaction ). A transaction is a set of database operations. Transactions are one of the core concepts in modern database theory. If a group of processing steps either occur or are not executed, we call the group processing steps as a transaction. When all the steps are fully executed like an operation, we say the transaction is committed. Because some or more of the steps fail to be committed, the transaction must roll back to the initial system status.

Seven attributes of spring transaction propagation:
PROPAGATION_REQUIRED -- supports the current transaction. If no transaction exists, a new transaction is created. This is the most common choice.
PROPAGATION_SUPPORTS -- supports the current transaction. If no transaction exists, it is executed in non-transaction mode.
PROPAGATION_MANDATORY -- supports the current transaction. If no transaction exists, an exception is thrown.
PROPAGATION_REQUIRES_NEW -- creates a transaction. If a transaction exists, it is suspended.
PROPAGATION_NOT_SUPPORTED -- executes operations in non-transaction mode. If a transaction exists, the current transaction is suspended.
PROPAGATION_NEVER -- runs in non-transaction mode. If a transaction exists, an exception is thrown.
PROPAGATION_NESTED -- if a transaction exists, it is executed within the nested transaction. If no transaction exists,
The operation is similar to PROPAGATION_REQUIRED.

Five isolation levels:
ISOLATION_DEFAULT this is a default isolation level of PlatfromTransactionManager, which uses the default transaction isolation level of the database.
The other four correspond to the JDBC isolation level;
ISOLATION_READ_UNCOMMITTED: This is the lowest isolation level of the transaction. It allows others to see the uncommitted data of this transaction.
This isolation level will generate dirty reads, which cannot be repeated and Phantom reads.

ISOLATION_READ_COMMITTED ensures that the data modified by one transaction can be read by another transaction only after it is committed. Another transaction cannot be read.
Uncommitted data of the transaction. This transaction isolation level can avoid dirty reads, but may cause non-repeated reads and Phantom reads.

The transaction isolation level of ISOLATION_REPEATABLE_READ can prevent dirty reads and prevent repeated reads. However, phantom reading may occur. It not only guarantees
A transaction cannot read the uncommitted data of another transaction, but it also ensures that the following conditions are avoided (it cannot be read repeatedly ).

ISOLATION_SERIALIZABLE this is the most costly but reliable transaction isolation level. Transactions are processed in sequence. In addition to preventing dirty reads,
This avoids phantom reading.

Keywords:
1) Phantom read: Transaction 1 reads the record current affairs 2 adds the record and submits it, and transaction 1 reads the record again to see the new record of transaction 2;
2) repeatable reading: When transaction 1 reads the record, transaction 2 updates the record and commits it. When transaction 1 reads the record again, the modified record of transaction 2 is displayed;
3) Dirty read: Transaction 1 updates the record but does not commit it. Transaction 2 reads the updated row and rolls back transaction T1. Currently, T2.

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.