Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dao pattern

 
narender sunkam
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I am very much confused with dao pattern
can any one explain me dao pattern with a simple example
I want some thing like discussion on this topic.
 
Maryam Nouhnejad
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be nice if you could write how much have you studied so far and what have made you confused in this subject...Anyway...

A typical DAO (Data Access Object) implementation has the following components:

�A DAO factory class
�A DAO interface
�A concrete class that implements the DAO interface
�Data transfer objects (sometimes called value objects)

You have to also know these assumptions behind the DAO implementation:

1 . All database access in the system is made through a DAO to achieve encapsulation.

2 . Each DAO instance is responsible for one primary domain object or entity. If a domain object has an independent lifecycle, it should

have its own DAO.

3 . The DAO is responsible for creations, reads (by primary key), updates, and deletions -- that is, CRUD -- on the domain object.

4 . The DAO may allow queries based on criteria other than the primary key. I refer to these as finder methods or finders. The return

value of a finder is normally a collection of the domain object for which the DAO is responsible.

5 . The DAO is not responsible for handling transactions, sessions, or connections. These are handled outside the DAO to achieve

flexibility.

So, which part of that do you intend to discuss with the others??...


Maryam
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our design forum...
 
narender sunkam
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maryam for responding
I have an doubt like how to implement dao pattern
can briefly explain me taking a small example
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google for "dao example". Study the examples and come back with more specific questions.

As an aside, I'd say that per default a DAO should return fully fledged domain objects, not DTOs. See http://www.martinfowler.com/bliki/LocalDTO.html
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blueprints: DAO Pattern
Core J2EE Patterns: Data Access Object

Note that there are other database access patterns besides the J2EE DAO
Active Record
Table Data Gateway, Row Data Gateway, Data Mapper
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic