3 Database access with Spring Data

 

This chapter covers:

  • Introduction to Spring Data, its needs, and various Spring Data Modules
  • Configuring a relational database, NoSQL database (MongoDB), and access data in a Spring Boot Application
  • Enabling Spring Data JPA to manage business domain objects with relational database
  • Various techniques to access data from a relational database using @NamedQuery, @Query, Criteria API and Querydsl

You’ve already explored a variety of topics on Spring Boot in the last two chapters. With a solid overview of Spring Boot, you’ve learned a few common tasks that you may use in your Spring Boot quite frequently. Now, what’s next? In today’s world, most applications are just incomplete without a database that stores the application data. Spring Boot applications are no exception to it. In this chapter, you’ll boot your journey by interacting with the database from your Spring Boot application. You’ll explore how seamless it is to perform database configuration, initialization, access data, and manage business objects in the database with Spring Boot!

3.1    Introducing Spring Data

Spring Data (https://spring.io/projects/spring-data) lets you access data from a variety of data sources (e.g., relational and non-relational databases, map-reduce databases, and cloud-based data services). It attempts to provide a uniform, easy-to-use, and familiar programming model through the Spring Framework.

3.1.1   Why Spring Data

 
 

3.1.2   Spring Data Modules

 
 

3.2    Configuring a Database in a Spring Boot Application

 
 
 
 

3.3    Understanding the CrudRepository Interface

 
 

3.4    Retrieve Data from a Database using Spring Data

 
 

3.4.1   Defining Query Methods

 

3.4.2   Implementing Pagination with PagingAndSortingRepository

 

3.4.3   Specifying Query using @NamedQuery

 
 
 

3.4.4   Specifying Query using @Query

 
 
 

3.4.5   Using Criteria API with Spring Data JPA

 
 

3.4.6   Using QueryDsl with Spring Data JPA

 

3.5    Managing Domain Object Relationships

 
 

3.6    Chapter Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest