Why ORM exists
Understand the object/table mismatch and what Hibernate actually buys you.
Open this lesson in the learning hubKey points
- Objects hold references. Tables hold foreign keys. Something has to translate between them. That translation is object-relational mapping.
- Plain JDBC means writing the same SELECT, row mapping and INSERT for every table. Hibernate generates that SQL from the shape of your class.
- It also remembers what it loaded, so changing a field is enough to produce an
UPDATE. No manual save plumbing. - The cost: SQL is generated, not written. When it is slow, you have to know what Hibernate did.
- Great for CRUD-shaped domains. Reach for plain SQL or jOOQ when the work is reporting and analytics.
Hibernate writes your SQL. You stay responsible for what that SQL costs.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Hibernate course, and every lesson in it is listed on the Hibernate contents page.