Seven things propagate property behavior and five isolation levels of spring things

Source: Internet
Author: User

First of all, talk about what business (Transaction). A transaction is a set of actions that manipulate a database.transaction is one of the core concepts in modern database theory. If a set of processing steps or all occurs or is not executed in one step, we call the group processing step a transaction. When all the steps are executed like an operation, we call the transaction to be committed. The transaction must be rolled back to the original system state because one or more of the steps failed, resulting in no step being committed.

Where spring seven things propagate properties:
Propagation_required--Supports the current transaction and creates a new transaction if there is no current transaction. This is the most common choice.
Propagation_supports-supports the current transaction and is executed in a non-transactional manner if no transaction is currently in use.
Propagation_mandatory--Supports the current transaction and throws an exception if there is no current transaction.
Propagation_requires_new--Creates a new transaction and suspends the current transaction if there is a transaction currently in place.
Propagation_not_supported--Performs the operation in a non-transactional manner, suspending the current transaction if a transaction is currently present.
Propagation_never--executes in a non-transactional manner and throws an exception if a transaction is currently present.
Propagation_nested--executes within a nested transaction if a transaction is currently present. If there is currently no transaction,
Do something similar to propagation_required.

Five isolation levels:
Isolation_default This is a platfromtransactionmanager default isolation level that uses the default transaction isolation level of the database.
The other four correspond to the isolation level of JDBC;
Isolation_read_uncommitted This is the lowest isolation level for transactions, and it allows a transaction to see uncommitted data for this transaction.
This isolation level produces dirty reads, non-repeatable reads, and Phantom reads.

Isolation_read_committed guarantees that a transaction modified data is committed before it can be read by another transaction. Another transaction cannot read
The data that the transaction did not commit. This level of transaction isolation avoids dirty reads, but non-repeatable reads and phantom reads can occur.

Isolation_repeatable_read This transaction isolation level prevents dirty reads and cannot be read repeatedly. However, Phantom reads may occur. It is in addition to guaranteeing
One transaction cannot read the uncommitted data of another transaction, and also ensures that the following conditions are avoided (non-repeatable read).

Isolation_serializable This is the most cost-effective, but most reliable, transaction isolation level. Transactions are processed for sequential execution. In addition to preventing dirty reading,
It is not repeatable to read, but also avoids phantom reading.

Keywords:
1) Phantom read: Transaction 1 reads record when transaction 2 adds record and commits, transaction 1 can see new record of Transaction 2 when read again;
2) Non-repeatable READ: Transaction 1 reads the record, transaction 2 updates the record and commits, transaction 1 can see the transaction 2 modified record after reading again;
3) Dirty read: Transaction 1 updated the record, but no commit, transaction 2 read the updated row, then the transaction T1 Rollback, now T2 read is invalid.

Seven things propagate property behavior and five isolation levels of spring things

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.