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
-
interfaceThis is the most generic interface. Here we define the CRUD operations
- AccountDao
-
interfaceThis defines extra entity-related operations
And two blocks are DBMS specific objects:
- JdbcDao
-
Abstract classProvide the abstraction to connect to different data sources (for instance JDBC)
- JdbcAccountDao
-
concrete classImplements the connection and the operation