Spring Data is a part of Spring Framework. The goal of Spring Data repository abstraction is to significantly reduce the amount of boilerplate code required to implement data access layers for various persistence stores.
Spring Data JPA is not a JPA provider. It is a library/framework that adds an extra layer of abstraction on the top of our JPA provider (like Hibernate).
Spring Data JPA Tutorials and Examples
This tutorial describes how you can create JPA repositories without writing any boilerplate code, and it consists of the following blog posts.
- Spring Data JPA Tutorial - Getting Started - This article provides a quick introduction to Spring Data JPA. It also describes all the important interfaces of Spring data commons and Spring Data JPA - Repository, CrudRepository, PagingAndSortingRepository, QueryDslPredicateExecutor, JpaRepository, JpaSpecificationExecutor
- Spring Data JPA Tutorial - Java Based Configuration - This post describes a complete example of how to configure Spring Data JPA with hibernate using Java-based configuration.
- Spring Data JPA - Query Creation from Method Names - In this article, we will learn how we can create query methods by using the query generation from the method name strategy. We will demonstrate this with a complete end-to-end example using Spring boot.
- Spring Data JPA - Creating Database Queries With Named Queries - In this article, we will learn to create database queries by using named queries. We will demonstrate this with a complete end-to-end example using Spring boot.
- Spring Data JPA @NamedNativeQuery and @NamedNativeQueries Example - In this article, we will learn how to create database queries using @NamedNativeQuery and @NamedNativeQueries annotations. These annotations let you define the query in native SQL by losing the database platform independence.
- Spring Data JPA - Creating Database Queries using @Query Annotation - This blog post describes how to create database queries using the @Query annotation. We will demonstrate this with a complete end-to-end example using Spring boot.
- Spring Data JPA - Auditing with Spring Boot 2 and MySQL Example - In this article, we will discuss how can we configure JPA to automatically persist the CreatedBy, CreatedDate, LastModifiedBy, and LastModifiedDate columns for any entity. We will create a simple Spring Boot CRUD REST APIs and we implement auditing using spring data JPA.
- Spring Data JPA - Working with Multiple Datasources using Spring Boot - In this article, we will learn how to configure multiple data sources and connect to multiple databases in a typical Spring Boot web application. We will use Spring Boot, JPA, Hibernate 5, Thymeleaf, and H2 database to build a simple Spring Boot multiple data source web application.
- Spring Data JPA Repository Testing using Spring Boot @DataJpaTest - In this article, we will learn how to test Spring Data JPA Repositories using Spring Boot provided @DataJpaTest annotation.
- Spring @Repository Annotation - In this quick article, we will discuss how to use @Repository annotation in Spring-based applications. DAO or Repository classes usually represent the database access layer in an application and should be annotated with @Repository.
- Spring MVC 5 + Spring Data JPA + Hibernate 5 + JSP + MySQL Tutorial - In this tutorial, we will discuss the integration of Spring MVC 5, Spring Data JPA, Hibernate 5, and MySQL CRUD example. We will demonstrate CRUD(Create, Retrieve, Update, Delete) operations on a Customer entity as well as display a list of customers from the MySQL database.
- Pagination and Sorting with Spring Boot, ThymeLeaf, Spring Data JPA, Hibernate, MySQL - In this tutorial, we will learn how to implement pagination and sorting operations using Spring Boot, Thymeleaf, Spring Data JPA, Hibernate, and MySQL database.
- Pagination and Sorting using Spring Data JPA - PagingAndSortingRepository - In this article, we will learn how to implement pagination and sorting using Spring Data JPA.
API Mapping of Spring Data JPA and JPA
The SimpleJpaRepository class provides the default implementation of a Repository interface. SimpleJpaRepository class internally uses JPA EntityManager to map its methods with JPA EntityManager interface methods.
It is better to know which JPA EntityManager method is being called by methods of Repository interface (SimpleJpaRepository class ) of Spring Data JPA.
The JPA methods called by the main methods of the Repository interface of Spring Data JPA are shown below.
Basic Spring Data JPA Flow
Once you completed reading above all articles then let's understand the basic flow at the time of accessing the database using Spring Data JPA is shown below.
Nice Tutorial. Really Informative.
ReplyDeleteCan you post sample working Java examples for below items
ReplyDelete1. Spring Data Java 8 Support
2. Spring Data Annotations
I went thru baeldung website but it's difficult to understand. There is no working code.
Yes, i will let you know once i will work on it.
DeleteYou are super awesome!!
ReplyDelete