Reputation: 145
where to define transaction boundries in java (@Service or @DAO level), Any Suggestions
We need to manage transaction between multiple services.
Upvotes: 0
Views: 159
Reputation: 4196
Depending on your persistence technology some kind of transactions might be needed to persist anything at all. Thus you may want a transaction on a DAO-level for e.g. testing the DAO layer. If e.g. controllers have direct access to DAOs you'll need transactions on DAOs, too.
What you may want to do is declaring a transaction on the service-level and the DAO-level reusing a provided transaction.
Read the great spring reference on transactions as well as the spring data reference for ideas.
Upvotes: 1
Reputation: 1529
Usually I recommend to use Transaction in Service, but it depends on.... In case of Service,you will get ability to create batch of actions in the one transaction.
For example start transaction. read, modify more than one entities, update, delete whatever. close transaction.
Upvotes: 1