Example & Tutorial understanding programming in easy ways.

What are the various transaction isolation isssues in Hibernate?

Transaction Isolation Issues in Hibernate: The transaction isolation means that a transaction is running, it seems the system only a transaction, other concurrent transactions do not exist. In most cases, it is rarely used completely isolated transaction. But not completely isolated from the transaction will bring about the following issues.


Some Transaction isolation issues are as:


1. Lost update (Lost Update): two transactions attempt to update a row of data causes the transaction to throw an exception exit, two transactions updated in vain. 


2. Dirty data (Dirty Read): If the second application uses the first application to modify the data, and this data is not submitted, then the dirty read occurs. The first application may then request a rollback modified data, which leads to the second transaction data is corrupted, the so-called "dirty". 


3. Unrepeatable (unrepeatable Read): a transaction twice read the same rows of data, but this data is not read twice, called non-re-read. If a transaction before the data is submitted, another transaction can modify and delete these data, will not be re-read. 


4. The magic read (Phantom Read): a transaction performed two queries, the second query results than the first query a row, this may be because another transaction insert a new row between the two queries. 

The problem caused by the transaction does not complete isolation, some isolation level is used to prevent these problems. 


5. The read operation uncommitted (Read Uncommitted): a transaction before submitting the changes for other transactions is visible. This dirty reads, unrepeatable and phantom reads are allowed. When a transaction has been written to a row of data but did not submit other matters can no longer write this line of data; However, any transaction can read any data. This isolation level use row write lock. 


6. Read operation has been submitted (Read Committed): read uncommitted data is not allowed, it uses the temporary were read locks and exclusive write locks to achieve. This isolation level does not allow dirty reads, but can not be re-read and phantom reads are allowed. 


7. Reread (Repeatable Read): transactional guarantees to be able to read the same data again without fail. This isolation level does not allow dirty reads and non-re-read, but phantom reads occur. 


8. Serializable (Serializable): to provide the most stringent transaction isolation. This isolation level does not allow transactions executed in parallel, allowing only serial execution. In this way, dirty reads, not re-read or phantom reads can occur.

Read More →