October 2017
Intermediate to advanced
396 pages
10h 2m
English
As the best approach, the service layer of the application is the best place to demarcate the transactions. Let's see this in the following code:
@Service
public class TransferServiceImpl implements TransferService{
//...
@Transactional
public void transfer(Long amount, Long a, Long b){
// atomic unit-of-work
}
//...
}
As you can see in the preceding code, TransferServiceImpl is our service class at the service layer of the application. This service is the best place to demarcate the transactions for units of work. Spring provides the @Transactional annotation to demarcate the transactions; this annotation can be used at either the class level or the method level of the service classes in the ...
Read now
Unlock full access