aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes what is the difference between DTO and DAO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "what is the difference between DTO and DAO" Watch "what is the difference between DTO and DAO" New topic
Author

what is the difference between DTO and DAO

goonn kantha
Greenhorn

Joined: Oct 24, 2005
Posts: 2
Can, anyone explain the differences between DTO and DAO.

It would be better if explained with an example.

Thanks,
kantha
Torsten Schippel
Ranch Hand

Joined: May 09, 2003
Posts: 62
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html


HTH
Torsten
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Moving this to the OO and Design Patterns forum.

This forum is for Servlets only questions, please try to post your thread in the most appropriate forum, and not just the first one on the list. (It's the morning, and I not a good morning person, that is why this sounds grumpy. Sorry.)

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Different is an "A" and a "T".

DAO is a class that usually has the CRUD operations like save, update, delete. Whereas the DTO is just an object that holds data. It is really a glorified JavaBean with instance variables and setter and getters. Usually it is the DTO that is passed to the save method of a DAO.

Data Access Object (DAO)
Data Transfer Object (DTO).

But check out the link posted above, I am sure it goes into much more detail.

Mark
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
See also http://faq.javaranch.com/view?DataTransferObject and http://faq.javaranch.com/view?DataAccessObject


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
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
DTO is also commonly known as VO or Value Object.



SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Paul Michael Laborte:
DTO is also commonly known as VO or Value Object.


Value Object is the old name for the J2EE pattern. The J2EE patterns team hadn't noticed that there already was a Value Object pattern with a different meaning in popular use. When they discovered that their pattern also already existed under the name of Data Transfer Object, they decided to rename it to Transfer Object for J2EE... :roll:
Naveen Sundaram
Greenhorn

Joined: Jul 31, 2008
Posts: 5
DAO contains the implementation of Data calls say insert ,update ,delete but DTO's are mere accessors ie, getters and setters used to fetch the data...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the difference between DTO and DAO