5.1. Mapping class inheritance

A simple strategy for mapping classes to database tables might be "one table for every entity persistent class." This approach sounds simple enough and, indeed, works well until we encounter inheritance.

Inheritance is such a visible structural mismatch between the object-oriented and relational worlds because object-oriented systems model both is a and has a relationships. SQL-based models provide only has a relationships between entities; SQL database management systems don't support type inheritance—and even when it's available, it's usually proprietary or incomplete.

There are four different approaches to representing an inheritance hierarchy:

  • Table per concrete class with implicit polymorphism—Use no explicit ...

Get Java Persistence with Hibernate now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.