Isolation level for spring transactions
1. Isolation_default: This is a platfromtransactionmanager default isolation level, using the default transaction isolation level of the database.
The other four correspond to the isolation level of JDBC
2. Isolation_read_uncommitted: This is the lowest isolation level of a transaction, which allows a foreign transaction to see the uncommitted data for this transaction.
This isolation level produces dirty reads, non-repeatable reads, and Phantom reads.
3. isolation_read_committed: Ensure that a transaction modified data is committed before it can be read by another transaction. Another transaction cannot read uncommitted data for the transaction
4. Isolation_repeatable_read: This transaction isolation level prevents dirty reads and cannot be read repeatedly. However, Phantom reads may occur.
In addition to ensuring that one transaction cannot read uncommitted data from another transaction, it ensures that the following conditions are avoided (non-repeatable read).
5. 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, non-repeatable reading, but also avoids phantom reading.
What is dirty data, dirty reading, non-repeatable reading, hallucination reading?
Dirty read: Refers to when a transaction is accessing the data, and the data has been modified, and this modification has not been committed to the database, at this time,
Another transaction accesses the data and then uses that data. Since this data is data that has not yet been submitted, another
The data that is read by a transaction is dirty, and the operation based on dirty data may not be correct.
Non-repeatable read: Refers to reading the same data multiple times within a transaction. When this transaction is not finished, another transaction accesses the same data.
Then, between the two read data in the first transaction, the data that was read two times by the first transaction because of the modification of the second transaction
May not be the same. This occurs when the data that is read two times within a transaction is not the same and is therefore called non-repeatable read.
Illusion reading: A phenomenon that occurs when a transaction is not executed independently, for example, when the first transaction modifies data in a table, this modification involves
To all rows of data in the table. At the same time, the second transaction modifies the data in the table by inserting a new row of data into the table. So
In the future, the user who operates the first transaction finds that there are no modified rows of data in the table, as if the illusion had occurred.
Spring Transaction ISOLATION LEVEL