File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes DAO & DTO Difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "DAO & DTO Difference?" Watch "DAO & DTO Difference?" New topic

DAO & DTO Difference?

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
What is the difference between Data Access Object and Data Transfer Object?

Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10033

A DAO is where you can ask for data and with a DTO you transfer the asked data from one layer to another.

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

A Data Access Object abstracts and encapsulates logic needed to access a given data source, such as a relational database, and performs these data access operation on behalf of a business object. See CoreJ2EE Patterns - Data Access Object for more details.

A (Data) Transfer Object is basically a (serializable) data container that encapsulates the (partial) state of a business object. So, a DAO may use a DTO to transfer the persistent state of a business object to and from a particular data source. See CoreJ2EE Patterns - Transfer Object for more details.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
With other words, the only thing they have in common is that they both have the words "Data" and "Object" in their name.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
Thanks everyone.
Jelle, is that complete book online or its just a catalog?
I agree. Here's the link:
subject: DAO & DTO Difference?
It's not a secret anymore!