From the course: Java Persistence with JPA

Unlock the full course today

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

Demo: Utilizing inheritance mapping strategies

Demo: Utilizing inheritance mapping strategies - Java Tutorial

From the course: Java Persistence with JPA

Demo: Utilizing inheritance mapping strategies

- [Instructor] Let's see these mapping strategies in action. For this example, we'll use the inheritance relationship between the employee, active employee, and retired employee to demonstrate the three main strategies. In the single table strategy, and if you notice here, I've navigated to the employee class on line 11, we are using the single table strategy. All the classes in the hierarchy are mapped to a single table. Let's run this code, and we'll take a look at it. So here we have employee, we have active employee, which extends employee. We also have retired employee, which also extends employee. In the base class, we are using single table. The code ran successfully. Let's see how this single table strategy is modeled in the database. Let's navigate to PG Admin, and let's select all from employees. Notice all of the attributes are defined in this single table. What are some of the pros and cons of the…

Contents