DAO (Data Access Object)

The DAO patter:

  • Makes the process of persisting data easier
  • Provides a very abstract interface that hides both the underlying database implementation and the mechanism or framework that is being used to persist data to the database.

DAO Blocks

There are four fundamental blocks.

Two blocks are business specific:

GenericDao
interface

This is the most generic interface. Here we define the CRUD operations

AccountDao
interface

This defines extra entity-related operations

And two blocks are DBMS specific objects:

JdbcDao
Abstract class

Provide the abstraction to connect to different data sources (for instance JDBC)

JdbcAccountDao
concrete class

Implements the connection and the operation