TimeToCodeTheRoad
TimeToCodeTheRoad

Reputation: 7312

Hibernate Design question

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

Answers (1)

Jafoy
Jafoy

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

Related Questions