Data Access Object

From Wikipedia, the free encyclopedia

This article is about the Data Access Object design pattern in object-oriented software design, not about the Data Access Objects library from Microsoft.

In computer software, a Data Access Object (DAO) is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing details of the database. This isolation separates the concerns of what data accesses the application needs, in terms of domain-specific objects and data types (the public interface of the DAO), and how these needs can be satisfied with a specific DBMS, database schema, etc. (the implementation of the DAO).

This design pattern is equally applicable to most programming languages, most types of software with persistence needs and most types of database, but it is traditionally associated with J2EE applications and with relational databases accessed via the JDBC API because of its origin in Sun Microsystems' best practice guidelines[1] ("Core J2EE Patterns") for that platform.

Contents

[edit] Advantages

The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application which can and should know almost nothing of each other, and which can be expected to evolve frequently and independently. Changing business logic can rely on the same DAO interface, while changes to persistence logic do not affect DAO clients as long as the interface remains correctly implemented.

In the specific context of the Java programming language, Data Access Objects can be used to insulate an application from the particularly numerous, complex and varied Java persistence technologies, which could be JDBC, JDO, EJB CMP, TopLink, Hibernate, iBATIS, or many others. Using Data Access Objects means the underlying technology can be upgraded or swapped without changing other parts of the application.

[edit] See also

[edit] External links

[edit] Tools

  • Google Persist Persist is a no-nonsense Java-based ORM/DAO tool.
  • ComtorDao ComtorDao a easy to DAO
  • DB Solo JDBC/EJB 3.0 DAO code generator
  • MDAOG DAO code generator for PostgreSQL databases
  • CodeFutures (Firestorm/DAO) DAO + DTO + Web Tier code generator for JDBC, EJB 2.0, JPA, Hibernate

[edit] References

  1. ^ Core J2EE Patterns - Data Access Objects. Sun Microsystems Inc. (2007-08-02).