Spring Propagation Properties
Propagation_required:
The method must be running in a transaction. If a transaction is running, the method will run in this transaction. Otherwise, a new transaction is started.
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
Avoid dirty reading prone to repetitive reading and phantom reading
4. Isolation_repeatable_read
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).
Avoid dirty read repeat read may appear phantom read
5. Isolation_serializable This is the most cost-effective, but most reliable, transaction isolation level. Transactions are processed for sequential execution.
Prevent dirty reading, non-repeatable reading, but also avoid phantom reading.
What is dirty data, dirty reading, non-repeatable reading, hallucination reading?
1. Dirty Read (Dirty Reads):
A transaction begins reading a row of data but another transaction has updated the data but failed to commit it in time. This is quite dangerous and it is possible that all operations are rolled back. (modification caused)
2. Non-repeatable read (non-repeatable Reads):
a transaction repeatedly reads the same row of data two times but gets different results. For example, there is another transaction in the middle of a two read that modifies the row's data and commits it (modified and not committed)
3. Phantom Read (Phantom Reads): Also known as Phantom (Phantom).
The transaction is queried two times during the operation, and the second query results in the data that did not appear in the first query (the same is not required for two queries in this case) because there is another transaction inserted into the data during the two queries.
(caused by adding a new record)
This article is from the "w51spring" blog, make sure to keep this source http://w51spring.blog.51cto.com/7524892/1772117
Transaction, propagation properties, and isolation levels for spring