solation is one of the common ACID properties: Atomicity, Consistency, Isolation, and Durability. Isolation describes how changes applied by concurrent transactions are visible to each other.
Each isolation level prevents zero or more concurrency side effects on a transaction:
Dirty read: read the uncommitted change of a concurrent transaction
Nonrepeatable read: get different value on re-read of a row if a concurrent transaction updates the same row and commits
Phantom read: get different rows after re-execution of a range query if another transaction adds or removes some rows in the range and commits
We can set the isolation level of a transaction by @Transactional::isolation. It has these five enumerations in Spring: DEFAULT, READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE.
4.1. Isolation Management in Spring
The default isolation level is DEFAULT. As a result, when Spring creates a new transaction, the isolation level will be the default isolation of our RDBMS. Therefore, we should be careful if we change the database.
We should also consider cases when we call a chain of methods with different isolation. In the normal flow, the isolation only applies when a new transaction is created. Thus, if for any reason we don't want to allow a method to execute in different isolation, we have to set TransactionManager::setValidateExistingTransaction to true.
Then the pseudo-code of transaction validation will be:
https://www.baeldung.com/spring-transactional-propagation-isolation