The joined inheritance strategy maps every class in an entity hierarchy to its own relational table. A subclass row shares its primary key with the superclass row, while a foreign key preserves the relationship. Retrieving a subclass requires joining its table with the superclass table. section 7.4
Mapping BillingDetails and its subclasses
Annotate the root entity with @Inheritance(strategy = InheritanceType.JOINED). BillingDetails maps to BILLINGDETAILS; BankAccount maps its declared fields to BANKACCOUNT, and CreditCard maps its fields to CREDITCARD. The subclasses inherit the identifier, so an explicit @PrimaryKeyJoinColumn is optional when the key names match. Each subclass key also references BILLINGDETAILS.ID. section 7.4
Unlike discriminator-based single-table mapping, JOINED requires no discriminator. Hibernate identifies concrete subclasses by checking joined subclass rows; polymorphic queries commonly use outer joins and CASE expressions, while concrete subclass queries use an inner join. section 7.4
Use JOINED when the relational model benefits from normalized tables and strong constraints.
- Prefer it when subclasses declare many non-optional properties and differ mainly in the data they hold. section 7.7
- Expect straightforward schema evolution and integrity-constraint definition; foreign keys to a subclass table can represent associations to that subclass. section 7.4
- Evaluate real SQL execution plans when hierarchy width, depth, or join cost may make TABLE_PER_CLASS preferable. section 7.7
A hierarchy diagram makes the one-table-per-class layout and shared-key links immediately visible. section 7.4
