- Data access object
-
- This article is about the data access object design pattern in object-oriented software design. For the Microsoft library of the same name, see Data Access Objects.
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. It provides a mapping from application calls to the persistence layer. 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 Java EE 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
Advantages
The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application that 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 as a design concept can be implemented in a number of ways. This can range from a fairly simple interface that separates the data access parts from the application logic, to frameworks and commercial products. DAO coding paradigms can require some skill. Use of technologies like Java persistence technologies and JDO ensures to some extent that the design pattern is implemented. Technologies like Enterprise JavaBeans come built into application servers and can be used in applications that use a JEE application server. Commercial products like TopLink are available based on Object-relational mapping (ORM). Popular open source ORM products include Hibernate, Ebean, pureQuery, iBATIS and Apache OpenJPA.
The expected benefit of use of Data Access Objects in a Java scenario is:
- Improved efficiency and performance of the data layer since it is standard reusable software.[citation needed]
- Modifications can be made to the DAO implementation without altering other decoupled modules of the application.
See also
- Create, read, update and delete (CRUD)
- Data Access Layer
- Data Transfer Object
- Design Patterns (book)
- Object-relational mapping
- Service Data Objects
External links
- Core J2EE Patterns - Data Access Object
- Data Access Objects versus Object Relational Mapping
- Inner Class strategy
Tools and Frameworks
- AuDAO Generator for JDBC DAO (MySQL, Oracle) and Google App Engine datastore
- CodeFutures (Firestorm/DAO) Generator for JDBC DAO, Spring DAO, Hibernate DAO
- ComtorDAO Data Access Object Library for java Data Access Object Library for java
- DB Solo EJB 3.0 DAO code generator
- EasyDriver Java libray to create queries in order to be used in a DAO context.
- IBM pureQuery data access platform
- JingDAO DAO framework
- MDAOG DAO code generator for PostgreSQL databases
- nHydrate DAO/DTO framework, code generator for .NET
- ODB compiler-based object-relational mapping (ORM) system for C++
- ORMLite Lightweight Object Relational Mapping (ORM) Framework in Java for JDBC and Android
- PerfectJPattern Open Source Project, Provides componentized implementation of the DAO Pattern in Java (JPA, Hibernate and Spring)
- Persist ORM tool
- Simplest ORM
- EclipseLink Delivers a comprehensive open-source Java persistence solution addressing relational, XML, and database web services.
References
- ^ "Core J2EE Patterns - Data Access Objects". Sun Microsystems Inc.. 2007-08-02. http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html.
Categories:- Software design patterns
Wikimedia Foundation. 2010.