In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how many isolation levels of Spring transactions are there". In daily operation, I believe that many people have doubts about the isolation levels of Spring transactions. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the doubts about "how many isolation levels of Spring transactions are there?" Next, please follow the editor to study!
What is a transaction?
A transaction is the execution of operations that either succeed or fail in order to maintain data consistency.
What is the principle of transaction management?
AOP
What is the nature of the transaction?
ACID
-- which Bean needs to be configured for transaction management in Spring?
Transaction manager, transaction definition Bean, transaction aspect, transaction annotation support
What is the purpose of the transaction definition?
Tell the transaction management framework how to manage transactions.
How many ways are there to define it?
Xml, comments
What can be defined?
① xml mode: readOnly= ""
Isolation level
Communication behavior
Under what kind of exception does not roll back
Define the circumstances under which to roll back
Timeout rollback
The ② annotation mode @ TransactionDefinition is an interface
Insert source code
Public interface TransactionDefinition {
Int getPropagationBehavior ()
Int getIsolationLevel ()
Int getTimeout ()
Boolean isReadOnly ()
String getName ()
}
Transaction manager
7 kinds of communication behavior
Quarantine level? Species
The degree of isolation of transaction work
The name of the transaction
Returns whether it is read-only
Click @ Transactional to find an enumerated type of Isolation and define several isolation levels.
Public enum Isolation {
/ * Use the default isolation level of the underlying datastore. * All other levels correspond to the JDBC isolation levels. @ see java.sql.Connection * / DEFAULT (TransactionDefinition.ISOLATION_DEFAULT)
/ * * A constant indicating that dirty reads, non-repeatable reads and phantom reads * can occur. This level allows a row changed by one transaction to be read by * another transaction before any changes in that row have been committed * (a "dirty read"). If any of the changes are rolled back, the second * transaction will have retrieved an invalid row. @ see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED * / READ_UNCOMMITTED (TransactionDefinition.ISOLATION_READ_UNCOMMITTED)
/ * * A constant indicating that dirty reads are prevented; non-repeatable reads * and phantom reads can occur. This level only prohibits a transaction * from reading a row with uncommitted changes in it. @ see java.sql.Connection#TRANSACTION_READ_COMMITTED * / READ_COMMITTED (TransactionDefinition.ISOLATION_READ_COMMITTED)
/ * * A constant indicating that dirty reads and non-repeatable reads are * prevented; phantom reads can occur. This level prohibits a transaction * from reading a row with uncommitted changes in it, and it also prohibits * the situation where one transaction reads a row, a second transaction * alters the row, and the first transaction rereads the row, getting * different values the second time (a "non-repeatable read"). @ see java.sql.Connection#TRANSACTION_REPEATABLE_READ * / REPEATABLE_READ (TransactionDefinition.ISOLATION_REPEATABLE_READ)
/ * * A constant indicating that dirty reads, non-repeatable reads and phantom * reads are prevented. This level includes the prohibitions in * {@ code ISOLATION_REPEATABLE_READ} and further prohibits the situation * where one transaction reads all rows that satisfy a {@ code WHERE} * condition, a second transaction inserts a row that satisfies that * {@ code WHERE} condition, and the first transaction rereads for the * same condition, retrieving the additional "phantom" row in the second read. @ see java.sql.Connection#TRANSACTION_SERIALIZABLE * / SERIALIZABLE (TransactionDefinition.ISOLATION_SERIALIZABLE)
Private final int value
Isolation (int value) {this.value = value;}
Public int value () {return this.value;}
}
The source code indicates that there are five isolation levels for Spring transactions.
DEFAULT: the default isolation level, which follows the isolation level of the database. Mysql adopts the default isolation level.
Can be read repeatedly. Oracle defaults to read submitted.
READ_UNCOMMITTED: read uncommitted, lowest isolation level
READ_COMMITTED: read submitted
REPEATABLE_READ: repeatable
SERIALIZABLE: serialization, highest isolation level, transaction execution in turn, poor performance
The concept of time for space
Will there be many kinds of TransactionManager?
Follow the framework and support different transaction management
-- what is local affairs? What is a distributed transaction?
Local transactions are database transactions, and distributed transactions are multi-data source transactions.
-- Spring transaction management interface
PlatformTransactionManager enable, submit, rollback
TransactionDefinition transaction definition
TransactionalStatus transaction status
At this point, the study on "how many isolation levels of Spring transactions are there" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.