Hooking the DAO layer
DAO is a design pattern that stands for Data Access Object. Following the separation of logic principle, DAO separates the data persistence logic in a dedicated layer and abstracts away the low-level database operations. Typically, the DAO is sketched around three main components:
- A model representing the data that is transferred between layers (for example, the
Sale
model corresponds to theSALE
database table) - An interface containing the API that should be implemented for the model (for example,
SaleDao
, or in Spring terms,SaleRepository
) - A concrete implementation of this interface (for example,
SaleDaoImpl
, or in Spring terms,SaleRepositoryImpl
)
The following diagram represents the relationships between these components using Sale
, SaleRepository
, and SaleRepositoryImpl
:
If you are a JdbcTemplate
fan, you most probably recognize this pattern in your own applications. On...