Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Guide · Web DevelopmentFree

Spring Data JPA Reference Documentation

The official reference for Spring Data JPA: repositories, query methods, @Query, projections, specifications, locking and transactions on top of JPA and Hibernate. Explains what your one-line repository methods really run against the database.

GitHub stars

3.3k (spring-data-jpa)

GitHub · Sept 2026

Reference version

4.1.1 (stable)

Spring docs · Sept 2026

Format

Guide

Topic

Web Development

Provider

Broadcom (Spring team)

Time needed

A week alongside a Spring Boot project

Level

Intermediate

Access

Free

What Spring Data JPA is

Spring Data JPA is the Spring project that sits on top of JPA, the standard Java API for mapping classes to relational tables, and Hibernate, the library that does the mapping in a Spring Boot app. Its big idea is the repository: you declare an interface such as PostRepository extends JpaRepository<Post, Long>, and Spring writes the implementation for you, including queries derived from method names. This reference, maintained by the Spring team, covers the 4.1.x line as of September 2026.

What the reference covers

  • Getting started and core concepts: entities, repository interfaces and the choice between Repository, ListCrudRepository and JpaRepository.
  • Configuration and entity persistence: how save decides between insert and update, and how entities are tracked.
  • Query methods: derived queries such as findByAuthorIdOrderByCreatedAtDesc, @Query with JPQL or native SQL, paging and sorting with Pageable.
  • Projections: interface and record based projections that load only the columns a response needs.
  • Specifications and Query by Example for dynamic filters.
  • Transactionality and locking: default transaction settings on repositories, @Transactional and optimistic and pessimistic locks.
  • Auditing, custom repository implementations, AOT optimisations and an FAQ.

Is it worth reading, or is a tutorial enough?

A tutorial gets a repository working in ten minutes. The reference is what stops it becoming slow or surprising in production. It explains when a derived query name turns into a join, why save on a detached entity runs a select first, how projections avoid loading whole entities and how repository methods take part in transactions. Most performance problems in Spring apps come from queries nobody looked at, and these chapters show you what to look for.

What to read first

  1. Core concepts and repository interfaces.
  2. Query methods, including paging and sorting.
  3. Projections, before you write your first list endpoint.
  4. Transactionality and locking, before anything that moves money or stock.
  5. Specifications when your search screen needs optional filters.

Prerequisites

Java 17 or later, a working Spring Boot app, and basic SQL: tables, keys, joins and indexes. Knowing a little JPA, such as @Entity and @ManyToOne, helps, because Spring Data builds on it rather than replacing it.

Common questions

Is it free? Yes. It is open source under the Apache 2.0 licence.

Do I still need to learn SQL? Yes. You will read the SQL Hibernate generates to fix slow endpoints, and write migrations by hand with a tool such as Flyway.

What can I do after it? Build a clean data layer for a Spring Boot API with repositories, paged queries, projections and correct transaction boundaries.

Best for: Java developers using Spring Boot with PostgreSQL or another relational database who want their data layer to be fast and predictable.

backenddatabaseopen source

Ready to start?

Opens on Broadcom (Spring team) in a new tab.

Open resource
Link broken or out of date?

Report a problem

With "Spring Data JPA Reference Documentation". Only Tauseef reads this.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.