Neuquino has the correct answer , but it is not very clear and understandable, so I will try to rephrase it:
Usually you need one transaction for one service method, so you annotate the @Transactional service @Transactional , not the DAO level. (The great thing about Spring @Transactional annotation is that it does not depend on the underlying implementation, so there should usually not be any code at the service level that depends on your persistence level, for example, there are no Session or JPA EntityManager hibernation calls) . For unit testing DAOs, add @Transactional annotations to your test methods (your tests are services, not DAOs).
source share