JPA Entities and Relational Mappings
Bridge Java objects and relational SQL tables using Jakarta Persistence annotations, primary key generation, and relationship mappings.
01The object-relational impedance mismatch
In Java, we think in terms of rich objects, graphs, references, and inheritance: an Order object has a reference to a Customer object, and a list of OrderItem objects.
In relational databases (PostgreSQL, MySQL), data lives in flat two-dimensional tables with rows and columns, linked together by foreign key numbers (customer_id = 42).
This conceptual clash is known as the Object-Relational Impedance Mismatch.
JPA (Jakarta Persistence API) is the standard Java specification that bridges these two worlds. Hibernate is the battle-tested ORM (Object-Relational Mapper) library that implements JPA under the hood in Spring Boot.
Loading the rest of the lesson…