15 Working with Spring Data JDBC
This chapter covers
- Starting a Spring Data JDBC project
- Working with queries and query methods with Spring Data JDBC
- Building relationships using Spring Data JDBC
- Modeling embedded entities with Spring Data JDBC
As already introduced in chapter 2, Spring Data is an umbrella project containing many projects. The purpose is to simplify access to both relational and NoSQL databases by adhering to the Spring framework principles. In chapter 4, we analyzed in detail the principles and the capabilities of the Spring Data JPA project. The goal of Spring Data JDBC is to efficiently deal with JDBC-based repositories. It is a younger project from the family. It does not offer a series of JPA capabilities as caching or lazy loading, resulting in a simpler and limited ORM. However, it is growing and constantly introducing new features with each version.
But why would one need Spring Data JDBC, when we already have alternatives such as JPA, Hibernate, or Spring Data JPA? The truth is that ORM (Object-Relational Mapping) makes projects complex – and you were able to clearly see this going through the previous chapters of the book. There are situations when we would like to get rid of such complexity, at the same time taking the benefit of working with Spring, the most popular Java framework today. Which alternatives do we have?