Reputation: 4590
if a method from service layer calls a method from repository layer in the same transaction, then is it efficient to put readOnly attribute to service method or repository method?
Upvotes: 2
Views: 259
Reputation: 159844
The typical location for the @Transactional
annotation is in the service layer. Your service may call a number of repository methods so it is more efficient to have transactions spanning the single service call rather than have more for individual repository/DAO calls.
It is the correct approach if you have multiple DAOs injected into that service that need to work together in a single transaction.
Upvotes: 3