Data Access Object Mode
Data Access Object Pattern or DAO mode is used to separate low-level data access APIs or operations from advanced business services. The following are participants of the data access object model.
- Data Access Object Interface - This interface defines the standard operations to be performed on a model object.
- Data Access Object concrete class - This class implements the above interface. This class is responsible for getting data from a data source, which can be a database, xml, or other storage mechanism.
- Model Object/Value Object - This object is a simple POJO that contains a get/set method to store the data retrieved by using the DAO class.
We will create an Student object as a model or numeric object. StudentDao is the data access object interface. StudentDaoImpl is the entity class that implements the data access object interface. DaoPatternDemo, our demo class uses StudentDao to demonstrate the usage of data access object patterns.
Create a numeric object.
Create an entity class that implements the above interface.
Use StudentDao to demonstrate the use of data access object patterns.