This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Do we need DAO layer" Watch "Do we need DAO layer" New topic
Author

Do we need DAO layer

Charu Sama
Greenhorn

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 HIbernateTemplate.save() 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: http://aspose.com/file-tools
 
subject: Do we need DAO layer