From the course: Java Persistence with JPA and Hibernate

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Inheritance

Inheritance

- [Instructor] Inheritance is a concept that you use in object-oriented modeling where one class can inherit the features and behavior of another class. Essentially, we implement a parent-child relationship between classes. Why do you use inheritance? Well, there might be many reasons or benefits of using it. One of them is code reuse, and another is the ability to use polymorphism. However, in the relational model, there's no way of representing the concept of inheritance and there's no straightforward way to map class hierarchies into database tables. The Jakarta persistence specification provides four strategies for representing inheritance relationships. Mapped superclass, single table, joint table, table per class. Each of these strategies work with four different database structures. In the library, there are members, members can be students or teachers. So a member is a generic type and student and teacher inherit from it. Let's start with mapped superclass strategy. The member…

Contents