I have a method in service layer which does the update functionality to database.
@Transactional(propagation = Propagation.REQUIRES_NEW) public void update(final Object obj){ // some code here }
Now I want to know what is the isolation level for this method set by Spring framework?
I am a newbie to Spring, just wanted to make myself comfortable with transactions.
Please share some best practice and ways to set isolation level to avoid deadlocks and thus preventing same user trying to update his record from different browsers.
The default isolation level is REPEATABLE READ . Other permitted values are READ COMMITTED , READ UNCOMMITTED , and SERIALIZABLE .
Serializable – This is the highest isolation level. A serializable execution is guaranteed to be serializable. Serializable execution is defined to be an execution of operations in which concurrently executing transactions appears to be serially executing.
Default Hibernate Transaction Isolation Level For majority of databases it's Read Committed.
Propagation. REQUIRED is the default setting of a @Transactional annotation. The REQUIRED propagation can be interpreted as follows: If there is no existing physical transaction, then the Spring container will create one.
According to the docs (Isolation.DEFAULT
), it uses
Use the default isolation level of the underlying datastore.
As you are using the @Transactional
annotation, I would set the isolation level there, e.g.:
@Transactional(propagation=Propagation.REQUIRES_NEW, isolation=Isolation.SERIALIZABLE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With