I use Java, Spring Boot, CrudRepository and Postgresql.
How can set the isolation level in a CRUD Repo in Spring Boot or how can I set the isolation level in whole Spring Boot application.
I use Java, Spring Boot, CrudRepository and Postgresql.
How can set the isolation level in a CRUD Repo in Spring Boot or how can I set the isolation level in whole Spring Boot application.
Spring creates proxies
for all
the classes
annotated with @Transactional
– either on the class or on any of the methods
. The proxy allows the framework to inject transactional logic before and after the method being invoked – mainly for starting and committing the transaction.
If the transactional bean is implementing an interface, by default the proxy will be a Java Dynamic Proxy. This means that only external method calls that come in through the proxy will be intercepted – any self-invocation calls will not start any transaction – even if the method is annotated with @Transactional.
Isolation:
DEFAULT:
Use the default isolation level of the underlying database.
Read Uncommitted:
Allows dirty reads
Read Committed:
Does not allow dirty reads
Repeatable Read:
If a row is read twice in the same transaction, the result will always be the same
Serializable:
Performs all transactions in a sequence
You should refer this Question for more Details.