liveBook · Manning

Data layer

As explained in Spring Start Here, Second Edition

A persistence layer is a software layer responsible for storing and retrieving application data beyond the lifetime of a process.

The persistence layer stores and retrieves application data, including creating, reading, updating, and deleting it. In a Spring app, it is the part that talks to the database. section 14.0

Spring Data reduces the code needed to build this layer. You declare repository interfaces; Spring supplies their implementations at runtime. This gives the app a common set of abstractions across persistence technologies, while the chosen Spring Data module matches the technology in use. section 14.0 section 14.1

Repository contracts can provide:

  • Basic create, read, update, and delete operations through CrudRepository. section 14.5
  • Pagination and sorting through PagingAndSortingRepository. section 14.5
  • Custom operations, with queries specified using @Query or derived from method names. Use @Query for complex operations; data-changing queries such as INSERT, UPDATE, or DELETE require @Modifying. section 14.5
Figure 14.1 The Java ecosystem offers many various persistence technologies like Hibernate, JDBC, MongoDB, or others. Each technology has its own abstractions and class design. Spring Data offers a common abstraction layer over all these persistence technologies to simplify the use of multiple persistence technologies.

The diagram shows Spring Data’s common abstractions spanning persistence technologies with different APIs and designs. section 14.1

How Spring Start Here, Second Edition covers it

How deep it goes
Explains repository contracts, CRUD, pagination, sorting, and query methods, but does not detail their implementations.
Examples
Uses JDBC, Hibernate, and MongoDB as technology examples, and names repository contracts such as CrudRepository.
What you can do after
Build a Spring persistence layer by declaring repository interfaces and selecting a Spring Data module for the persistence technology.
How it connects
Connects Spring Data repositories with JDBC, Hibernate, MongoDB, and persistence technologies.

Also explained in

Compare how 8 books explain data layer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.