Reputation: 4324
Using Spring, I am reaching the following scenario.
I have a service that has to be @Transactional
because it calls several DAOs. But it also calls other services that are already @Transactional
.
Somehow, I will be calling nested @Transactional
services.
Will Spring manage well?
Upvotes: 4
Views: 2431
Reputation: 5207
@Transactional
without any explicit parameters uses propagation = REQUIRED
. This means:
The 2nd service (the nested one) annotated with @Transactional
will be executed in the same transaction as the 1st one (the outer one). You don't need to do anything.
In some cases if you want to explicitly separate the nested call from the outer one you can use propagation = REQUIRES_NEW
.
Upvotes: 3