liveBook · Manning

Spring Data REST

As explained in Java Persistence with Spring Data and Hibernate epub

Spring Data REST is a Spring Data project that exposes repository-backed data through RESTful resources.

Spring Data REST exposes Spring Data repositories as RESTful resources, allowing a Spring Boot application to manage persistent entities through HTTP rather than hand-written controllers. section 2.2 section 16.2

A practical Spring Data REST application combines:

  • Spring Web, Spring Data JPA, REST Repositories, and a MySQL driver in Maven. section 16.2
  • Spring Boot properties for the server port, datasource, Hibernate dialect, SQL logging, and schema generation. section 16.2
  • JPA entities, including a version field that supports conditional REST requests with ETags. section 16.2 section 16.7
  • A repository interface extending JpaRepository, which Spring Data REST can export automatically. section 16.2 section 16.4

Restricting the exported API

Map a repository to /users, disable deletion, and hide an entity field: @RepositoryRestResource(path = "users") on UserRepository, @RestResource(exported = false) on delete methods, and @JsonIgnore on isRegistered(). Requests to the disabled repository return 404, disabled deletion returns 405, and the ignored field disappears from REST responses. section 16.4

Figure 16.1 Creating a new Spring Boot project using Spring Data REST and MySQL

Use the project-creation figure to inspect the Spring Boot and MySQL setup that starts the application. section 16.2

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Builds a configured Spring Boot application and demonstrates repository, method, field, ETag, event, projection, and excerpt controls.
Examples
Uses a MySQL-backed User entity, UserRepository, /users requests, access annotations, and a CSV-loaded auction dataset.
What it assumes
Assumes basic Spring, Java, Maven, REST, and JPA familiarity while demonstrating repository configuration from project creation.
What you can do after
Build it from scratch with Spring Boot, configure persistence, expose repositories, and restrict exported operations and fields.
How it connects
Connects Spring Boot, Spring Data JPA, RESTful resources, ETags, REST events, projections, and excerpts.

Also explained in

Compare how 2 books explain Spring Data REST →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.