📄️ How Spring Talks to Databases
Before writing repositories and entity classes, it helps to understand what's happening in the layers below. Spring Boot makes database access feel effortless, but there's a real stack underneath. Knowing it saves you when things go wrong, and they will.
📄️ Reverse Engineering JPA Entities
The Problem
📄️ JPA Repository Usage
In the previous document we set up build-time entity generation from the Sakila schema. The JPA entities exist now, but nothing in the application uses them yet. This document wires them into the hexagonal architecture so the app can query the database, convert results to domain models, and handle the "not found" case cleanly.
📄️ Database Setup
The previous sections covered how Spring talks to databases and how to generate JPA entities. Now it's time to wire up a real database. We're replacing the embedded H2 with PostgreSQL 17 and using Flyway to manage schema migrations.
📄️ Pagination
Right now the GET /films endpoint returns every film in a single response. That works fine with a small dataset, but in production a table can hold thousands or millions of rows. Sending all of them at once wastes bandwidth, increases response times, and puts unnecessary load on both the server and the client.