To understand isolations level better, lets review the main colitions that may happend in concurrent
environment:
- lost update - A second transaction writes a second value of a data on top of a first value written by a first concurrent transaction, and the first value is lost to other transactions running concurrently which need, by their precedence, to read the first value.
- dirty read - insert or update data by transaction that will be rollbacked further
- non-repeatable read - first transaction read data, then read them again and the same data is modified
- phantom reads - on the second read in transaction, new data is appearing
So, now that's easy to describe isolation levels with the following table:
Isolation level | JDBC equivalent | Dirty reads | Non-repeatable reads | Phantoms | Lost update |
---|---|---|---|---|---|
None | TRANSACTION_NONE | may occur | may occur | may occur | may occur |
Read Uncommitted | TRANSACTION_READ_UNCOMMITTED | may occur | may occur | may occur | - |
Read Committed | TRANSACTION_READ_COMMITTED | - | may occur | may occur | - |
Repeatable Read | TRANSACTION_REPEATABLE_READ | - | - | may occur | - |
Serializible | TRANSACTION_SERIALIZABLE | - | - | - | - |