Motivated by a discussion in the Spring forum
, Debasish Ghosh
has blogged his views on using Repositories rather than DAOs
. The blog entry includes a code example that demonstrates the usefulness of this abstraction.
The first order of business is to level set everyone with a definition of DAO.
A DAO belongs to the data layer of the application, which encapsulates the internals of CRUD operations from the Java application being developed by the user using OO paradigms.
The definition is supported by a code example. Once this foundation is in place, Debasish quickly moves on to demonstrate how adding a repository as a domain object helps to clean up the primary domain objects. This addition works to remove the CRUD into a separate service layer that appears in the model as a domain object.
Debashish promises a follow up blog to demonstrate how DAOs can be replaced with an O/R mapping tool such as Hibernate