I am bit of unclear about the usage of @Transactional annotation in the business/service layer.
My question is, when used together with ISOLATION_SERIALIZABLE in business layer, does the @Transactional
annotation guaranty that no concurrent access is allowed to the particular method?
@Transactional(isolation = Isolation.SERIALIZABLE)
public void businessMethod() {
// calls subBusinessMethod
subBusinessMethod();
---------------
---------------
---------------
}
Imagine that subBusinessMethod
calls to the DAO layer to do some db transactions. The code execution(more db calls may be) after the call to subBusinessMethod
depends on the result of the db transaction took place in subBusinessMethod
.
I need to make sure that the subsequent calls to the businessMethod
should not call the dao layer to read/write from/to the database without knowing what happened to the db tables from previous calls. Required validations have been added in the business logic.
First of all, is my approach valid? If so, am I using it in the correct way. ?