OrderHub Day 1 stored orders in a HashMap — restart the server and they're gone. Day 2 fixes that: real persistence with JPA + PostgreSQL, and thanks to Day 1's layered design, the controller and service don't change a single line.

The payoff of a repository port

Day 1 defined an OrderRepository interface with an in-memory implementation. Day 2 adds a second implementation backed by JPA — and swaps it in. Same interface, new guts. The service depends on the port, so it never noticed.

JPA in three pieces

@Entity maps an OrderEntity to an orders table.