Spring Data is a family of Spring projects that simplifies access to relational and NoSQL databases. Its common approach to data access does not erase differences between stores: each module retains the capabilities of its underlying technology. section 2.2 section 4.0
For relational persistence, distinguish the layers. JPA specifies APIs and object/relational mappings; Hibernate can implement JPA; Spring Data JPA sits above a JPA implementation. It creates implementations of repository interfaces and can generate queries from method names, reducing persistence-layer boilerplate. JPA and Hibernate still define and manage the entities. section 1.3 section 2.2 section 4.0
Choose a module by the store and capabilities the application needs:
- Spring Data Commons supplies a metadata model for persistent Java classes and technology-neutral repository interfaces. section 2.2
- Spring Data JPA supports JPA-based repositories; Spring Data JDBC supports JDBC-based repositories but omits JPA capabilities such as caching and lazy loading. section 2.2
- Spring Data REST exports repositories as RESTful resources; Spring Data MongoDB supports document-database access; Spring Data Redis provides abstractions for key/value access. section 2.2
Spring Data JPA can take responsibility for configuration and transaction management, with Spring integration through JavaConfig or XML. Less handwritten data-access code does not remove the need to understand SQL: inspect generated queries and their performance implications, and anticipate the code that repository abstractions generate. section 4.0 section 1.3
