Content deleted Content added
rm whitespace |
|||
(6 intermediate revisions by 5 users not shown) | |||
Line 1:
{{Short description|Abstract interface to a computer database}}
{{About|the software design pattern|the Microsoft library|Jet Data Access Objects}}
Line 10 ⟶ 11:
| date = 2007-08-02
}}</ref> "Core J2EE Patterns".
This object can be found in the [[Data_access_layer|Data Access layer]] of the [[Multitier_architecture|3-Tier Architecture]].
There are various ways in which this object can be implemented:
* One DAO for each table.
* One DAO for all the tables for a particular DBMS.
* Where the SELECT query is limited only to its target table and cannot incorporate JOINS, UNIONS, subqueries and Common Table Expressions (CTEs)
* Where the SELECT query can contain anything that the DBMS allows.
== Advantages ==
All details of storage are hidden from the rest of the application (see [[information hiding]]). [[Unit testing]] code is facilitated by substituting a [[test double]] for the DAO in the test, thereby making the tests independent of the persistence layer.
Line 19 ⟶ 28:
In the context of the [[Java (programming language)|Java]] programming language, DAO can be implemented in various ways. This can range from a fairly simple interface that separates data access from the application logic, to frameworks and commercial products.
Technologies like [[Java Persistence API]] and [[Enterprise JavaBeans]] come built into application servers and can be used in applications that use a Java EE application server. Commercial products such as [[TopLink]] are available based on [[
== Disadvantages ==
Potential disadvantages of using DAO include [[leaky abstraction]],{{Citation needed|reason=What kind of leak?|date=August 2014}} [[Duplicate code|code duplication]], and [[abstraction inversion]]. In particular, the abstraction of the DAO as a regular Java object can obscure the high cost of each database access. Developers may inadvertently make multiple database queries to retrieve information that could be returned in a single operation. If an application requires multiple DAOs, the same create, read, update, and delete code may have to be written for each DAO.<ref>See http://www.ibm.com/developerworks/java/library/j-genericdao/index.html for workarounds</ref>
Note that these disadvantages only appear when you have a separate DAO for each table and the SELECT query is prevented from accessing anything other than the target table.
== Tools and frameworks ==
* [[ODB (C++)|ODB]] compiler-based [[
* ORMLite: Lightweight [[
* [[Entity Framework|Microsoft Entity Framework]]
* DBIx::Class [[
* TuxORM: Simple [[
* [[Persist (Java tool)]] Java-based [[
== See also ==
Line 36 ⟶ 47:
* [[Data access layer]]
* [[Service Data Objects]]
* [[
== References ==
{{Reflist}}
{{Design Patterns Patterns}}
|