File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Do we need DAO layer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Do we need DAO layer" Watch "Do we need DAO layer" New topic

Do we need DAO layer

Charu Sama

Joined: Aug 03, 2006
Posts: 12
Do we really need DAO layer if working with Hibernate, JPA or any other mapping framework. I had long discussion on this topic .....

Some says yes, but I donot know why??? just for or EntityManager.persist(), ?

Is this not a good design decision to omit DAO layer and let the Frameork do their jobs like generating SQL behind the secene, resource management.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
A well-designed DAO layer will enable loose/low coupling between data access logic, transaction management logic and business logic code.

Business object model classes containing business logic should not have data access code mixed in with the business logic. Data access logic involves much more than ".save" or ".persist" methods.

Ideally, business objects should have zero syntax-level dependencies upon commercial or open-source frameworks.

It is poor design and bad form to not have a DAO layer. The reasons and rationales are spelled out in documentation for the Data Access Object design pattern.
I agree. Here's the link:
subject: Do we need DAO layer
It's not a secret anymore!