Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the difference between DTO and DAO

 
goonn kantha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can, anyone explain the differences between DTO and DAO.

It would be better if explained with an example.

Thanks,
kantha
 
Torsten Schippel
Ranch Hand
Posts: 62
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See also http://faq.javaranch.com/view?DataTransferObject and http://faq.javaranch.com/view?DataAccessObject
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DTO is also commonly known as VO or Value Object.

 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic