JavaWeb Spring affairs --Transation

(This article is a summary of editors collected in the study notes, only to learn, if infringement, please contact me)

 

Transaction --Transation


What business is?

Transaction refers to a set of operations on the logical set of operations either all succeed, or all fail.

Things features:

1. Atomic Atomic: A transaction is an indivisible unit of work, either all operations in a transaction happen or none happen.

2. Consistency Consistent: transactional integrity of the data before and after processing must be consistent.

3. Isolation Isolated: When a plurality of users concurrent access to the database, a user's transaction can not be firm interfere with other users, data between a plurality of concurrent transactions to be isolated from each other.

4. Persistence Durable: Once a transaction is committed, it changed data in the database is permanent, even if the database fails nor should it have any impact.

Spring transaction management interface:

PlatformTransactionManager: Transaction Manager

TransactionDefinition: transaction definition information (transaction isolation level, propagation behavior)

TransactionStatus: Transaction specific operational state



(. 1) REPEATABLE_READ, Mysql isolation level defaults

(2) READ_COMMITTED using the Oracle default isolation level

 


If you do not consider isolation, it will lead to the following security issues:

 

1. dirty read . One transaction reads another transaction but not yet submitted to rewrite data, if the data is rolled back, the read data is invalid.

2. A non-repeatable read . In the same transaction, the result of multiple reads of the same data returned is different.

3. The phantom read . After a transaction reads a few rows, a second transaction inserts some records, phantom read occurs. Later query, the first transaction would not have found that some of the original recording.

 



 




 

 

Released five original articles · won praise 3 · Views 353

Guess you like

Origin blog.csdn.net/Young_IT/article/details/82797933