Download Data Access Object

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Database wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Microsoft Access wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database model wikipedia , lookup

Transcript
Data access object
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.
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 does 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 EJB CMP 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.
Popular open source ORM products include Hibernate, 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.
• It is also expected that in case the DAO implementation were to change the other parts of the application would
be unaffected.
Disadvantages
• As is common in Java, there are many open source and commercial implementations of DAO available. Each of
these can have potentially different implementation strategies and usage models. There is a familiarisation curve
involved with each of them.
• A certain amount of skill is required to implement a DAO design pattern or use a DAO product.
See also
•
•
•
•
Data access layer
Data Transfer Object
Design Patterns (book)
Object-relational mapping
• Service Data Objects
• Create, read, update and delete
1
Data access object
External links
• Core J2EE Patterns - Data Access Object [2]
• Inner Class strategy [3]
• Data Access Objects versus Object Relational Mapping [4]
Tools and Frameworks
Persist [5] ORM tool
DB Solo [6] EJB 3.0 DAO code generator
MDAOG [7] DAO code generator for PostgreSQL databases
CodeFutures [8] (Firestorm/DAO) Generator for JDBC DAO, Spring DAO, Hibernate DAO
JingDAO [9] DAO framework
PerfectJPattern Open Source Project [10], Provides componentized implementation of the DAO Pattern in Java
(JPA, Hibernate and Spring)
• nHydrate [11] DAO/DTO framework, code generator for .NET
• AuDAO [12] Generator for JDBC DAO (MySQL, Oracle) and Google App Engine datastore
• Simplest ORM [13]
•
•
•
•
•
•
References
[1] "Core J2EE Patterns - Data Access Objects" (http:/ / java. sun. com/ blueprints/ corej2eepatterns/ Patterns/ DataAccessObject. html). Sun
Microsystems Inc.. 2007-08-02. .
[2] http:/ / java. sun. com/ blueprints/ corej2eepatterns/ Patterns/ DataAccessObject. html
[3] http:/ / nils. kilden-pedersen. net/ DAO_pattern/ InnerClassStrategy. html
[4] http:/ / www. codefutures. com/ weblog/ andygrove/ archives/ 2005/ 02/ data_access_obj. html
[5] http:/ / code. google. com/ p/ persist/
[6] http:/ / www. dbsolo. com
[7] http:/ / mdaog. sourceforge. net
[8] http:/ / www. codefutures. com/ products/ firestorm/
[9] http:/ / jingdao. sourceforge. net/
[10] http:/ / perfectjpattern. sourceforge. net/ dp-genericdao. html
[11] http:/ / nhydrate. codeplex. com/
[12] http:/ / audao. spoledge. com/
[13] http:/ / code. google. com/ p/ simplestorm/
2
Article Sources and Contributors
Article Sources and Contributors
Data access object Source: http://en.wikipedia.org/w/index.php?oldid=358617423 Contributors: Abcdefg3381, Abdull, Ary29, Bravegag, Catmaniac85, Coldacid, Everyking, Fang Aili,
FatalError, Fred Bradstadt, Gravbox, Intgr, Khalid hassani, Krpeters, Leandrod, MacTed, Matiasmoreno, MistWiz, Moradan, Nomasfarc, Oorang, Peak, Plugwash, Pvlasov, RedWolf,
RichardJFoster, SMeeds, Sadovnikov, Sandeep 41, Signalhead, Ta bu shi da yu, The Wild Falcon, Torkjel, Ttennebkram, Txomin, Vbartacek, Vinay tawney, Vincentsharma, Web-Crawling
Stickler, Whiner01, Wikidrone, 101 anonymous edits
License
Creative Commons Attribution-Share Alike 3.0 Unported
http:/ / creativecommons. org/ licenses/ by-sa/ 3. 0/
3