7 Mapping inheritance

This chapter covers

  • Examining inheritance-mapping strategies
  • Investigating polymorphic associations

We deliberately haven’t talked much about inheritance mapping so far. Mapping makes the connection between the object-oriented world and the relational world, but inheritance is specific to object-oriented systems. Consequently, mapping a hierarchy of classes to tables can be a complex problem, and we’ll demonstrate various strategies in this chapter.

A basic strategy for mapping classes to database tables might be “one table for every persistent entity 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 ...

Get Java Persistence with Spring Data and 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.