IMHO transactions should go to the service level. Typically, a single business transaction consists of several requests and updates. If you place @Transactional only at the DAO level, each request and update will be performed in a separate transaction, which effectively defeats the purpose of the transaction.
But if the services are @Transactional , each database interaction connects to one main transaction when the web tier enters the service tier. Please note that in this case, if the web layer launches several maintenance methods, each of them will be launched in a separate transaction (the same problem moves up one level). But placing @Transactional in a web layer can lead to unexpected side effects, such as the N + 1 issue, that would be caught otherwise. Thus, try saving one business transaction in a single service method called from the web tier.
Tomasz Nurkiewicz
source share