4 Working with Spring Data JPA


This chapter covers

  • Overviewing Spring Data and its modules
  • Examining the main concepts of Spring Data JPA
  • Investigating the Query Builder mechanisms
  • Examining projections, modifying and deleting queries
  • Examining Query by Example

Spring Data is an umbrella project containing many projects specific to various databases. These projects are developed in partnership with the companies creating the technologies themselves. Spring Data intends to provide an abstraction for data access and maintain at the same time the underlying specificities (including here relational and non-relational databases).

Among the general features provided by Spring Data, we mention:

  • Integration with Spring via JavaConfig and XML configuration
  • Repository and custom object-mapping abstractions
  • Integration with custom repository code
  • Dynamic query creation based on repository methods names
  • Integration with other Spring projects, as Spring Boot

4.1 Introducing Spring Data JPA

4.2 Starting a new Spring Data JPA project

4.3 First steps to configure a Spring Data JPA project

4.4 Defining query methods with Spring Data JPA

4.5 Limiting query results, sorting, and paging

4.6 Streaming results

4.7 The @Query annotation

4.8 Projections

4.9 Modifying queries

4.10 Query by Example

4.11 Summary