Reputation: 7312
I have new to Hibernate! I wanted to inquire why do we normally have a service layer for hibernate. I mean if there are the DAOs, why do we need the service layers also?
Upvotes: 0
Views: 98
Reputation: 141
I use a separate layer to handle units-of-work/transactions. My DAOs are all quite simplistic and only handle straight database access. Often a single task will involve several DAO interactions, but be in a single transaction (update several tables, retrieve data and conditionally update, etc). By moving up a layer I can throw a @Transactional annotation on the task (assuming we're using Spring, but the concept holds without) and further encapsulate it.
Upvotes: 1