15 Working with Spring Data JDBC

 

This chapter covers

  • Starting a Spring Data JDBC project
  • Working with queries and query methods in Spring Data JDBC
  • Building relationships using Spring Data JDBC
  • Modeling embedded entities with Spring Data JDBC

We introduced Spring Data in chapter 2: it’s an umbrella project containing many projects whose purpose is to simplify access to both relational and NoSQL databases by adhering to the Spring framework principles. In chapter 4, we looked in detail at the principles and capabilities of the Spring Data JPA project. The purpose of Spring Data JDBC is to efficiently deal with JDBC-based repositories. It is a younger project in the family, and it does not offer all the JPA capabilities, such as caching or lazy loading, resulting in a simpler and more limited ORM. However, it is growing and introducing new features with each version.

Why would we need Spring Data JDBC, when we already have alternatives such as JPA, Hibernate, and Spring Data JPA? The truth is that object/relational mapping (ORM) makes projects complex, and you clearly saw this in the previous chapters. There are situations when we’ll want to eliminate this complexity and take the benefits of working with Spring, the most popular Java framework today. What alternatives do we have?

15.1 Creating a Spring Data JDBC project

15.2 Working with queries in Spring Data JDBC

15.2.1 Defining query methods with Spring Data JDBC

15.2.2 Limiting query results, sorting, and paging

15.2.3 Streaming results

15.2.4 The @Query annotation

15.2.5 Modifying queries

15.3 Modeling relationships with Spring Data JDBC

15.3.1 Modeling a one-to-one relationship with Spring Data JDBC

15.3.2 Modeling embedded entities with Spring Data JDBC

15.3.3 Modeling a one-to-many relationship with Spring Data JDBC

15.3.4 Modeling a many-to-many relationship with Spring Data JDBC

sitemap