DAO support and @Repository annotation

The standard way of accessing data is via specialized DAOs that perform persistence functions under the data access layer. Spring follows the same pattern by providing DAO components and allowing developers to mark their data-access components as DAOs, using the annotation @Repository. This approach ensures consistency over various data access technologies such as JDBC, Hibernate, JPA, and JDO, and project-specific repositories. Spring applies SQLExceptionTranslator across all these methods consistently.

Spring recommends your data-access components to be annotated with stereotype, @Repository. The term, repository, was originally defined in Domain-Driven Design, Eric Evans, Addison Wesley as "a mechanism ...

Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.