Chapter 4. Inheritance and Custom Mapping
Inheritance, polymorphic associations, and polymorphic queries are supported by entities. The JPA specification says that both concrete and abstract classes can be entities and can be mapped with the Entity
annotation. Non-entity classes and entity classes can extend each other. Hibernate provides the MappedSuperClass a
nnotation (@MappedSuperclass
) to enable inheritance mapping and to let you map abstract or concrete entity subclasses. The mapped superclass doesn't have its own separate table.
Hibernate provides four strategies for mapping an inheritance hierarchy:
Table per class hierarchy: The class hierarchy is represented in one table. A discriminator column identifies the type and the subclass.
Table ...
Get Hibernate Recipes: A Problem-Solution Approach 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.