patternjavaspringCritical
Where does the @Transactional annotation belong?
Viewed 0 times
annotationwherethetransactionalbelongdoes
Problem
Should you place the
@Transactional in the DAO classes and/or their methods or is it better to annotate the Service classes that are using the DAO objects? Or does it make sense to annotate both layers?Solution
I think transactions belong on the service layer. It's the one that knows about units of work and use cases. It's the right answer if you have several DAOs injected into a service that need to work together in a single transaction.
Context
Stack Overflow Q#1079114, score: 604
Revisions (0)
No revisions yet.