If you want to save time by writing less test code, take a look at my upcoming Test With Spring Course.

Spring Data JPA Tutorial


Creating repositories that use the Java Persistence API is a cumbersome process that takes a lot of time and requires a lot of boilerplate code.

We can remove some boilerplate code by creating an abstract base repository class that provides CRUD operations for our entities. This means that we can create concrete repositories by extending that base repository class. In other words, we have to write the code that provides CRUD operations only once.

The problem is that this does not eliminate all boilerplate code. We still have write the code that creates our database queries and invokes them. To make matters worse, we have to do this every time when we create a new database query.

This is a waste of time!

Spring Data JPA was created to solve this problem.

Introducing: Spring Data JPA Tutorial

I am currently updating my Spring Data JPA tutorial. This means that some parts of this tutorial will use a different example application than the original blog posts.

The New Tutorial

This tutorial describes how you can create JPA repositories without writing any boilerplate code, and it consists of the following blog posts

The Old Tutorial

This nine-part tutorial will help you to get started with Spring Data JPA. This tutorial is based on Spring Data JPA 1.0.2 but its information is also valid for newer versions of Spring Data JPA. On the other hand, if you are interested of reading about Spring Data JPA 1.2.0, you can start by taking a look at my Spring Data book.

Lets move on and find out what you can learn by reading this tutorial.

Congratulations. If you read every part of this tutorial, you know that implementing data access code does not have to be cumbersome. It can be fast, simple and fun.

It is time to put your new skills to use.

Additional Reading:

  • My Spring Data book helps you to create JPA repositories without any boilerplate code and tweak the performance of your applications with Spring Data Redis.
  • Spring Data Solr Tutorial describes how you can implement fast search functions with Spring Data Solr.
  • Using jOOQ with Spring helps you to get back in control of your SQL. If you are tired of solving ORM related performance problems, you should do yourself a favor and read this tutorial.

Other Resources

This section showcases useful material created by other developers. If you have written a blog post or recorded a video about Spring Data JPA, and want to include it to this section, ping me on Twitter and I will check it out. If I think that it is useful, I will add it to this section.

Java Persistence API

Reference Manuals and Official Guides

Blog Posts


Spring Data JPA

Reference Manuals and Official Guides

Blog Posts