Case Study

Data Access Layer

Previous Next
The data access layer manages the persistence of the domain model objects. Five interfaces - AccountDao, CategoryDao, ItemDao, OrderDao, and ProductDao - provide operations as defined by Spring's JPetstore sample application. The implementation of the case study introduces an additional inteface, Dao, that contains create/read/update/delete (CRUD) operations. Dao, a generic class, is extended by each of the other interfaces, and enables type-safe operations for each subclass. The data access layer of the case study is implemented using Hibernate as the object-relational mapping framework. The design separates general behavior (AbstractDao) from Hibernate-specific behavior (the rest of the classes). AbstractDao implements the CRUD operations and findAll method, and introduces several abstract methods to be implemented by framework-specific classes. AbstractHibernateSpringDao implements several of these abstract methods suitable for an implementation using Hibernate with Spring. The type-specific DAOs (e.g. AccountDaoHibernate) implement methods particular to the corresponding interface (e.g. AccountDao) as well as abstract methods left unimplemented by AbstractHibernateSpringDao.
Previous Next