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.

More inheritance strategies

More inheritance strategies

- [Instructor] Out of the four strategies for representing inheritance relationships provided by the Jakarta Persistence specification, another is the joint table strategy. Assume in the library that there are books that belong to different genres like fiction and nonfiction. So you can think of a hierarchy of classes where the genre is the parent and fiction and nonfiction are child classes. So here, there's a genre class, a fiction class, and a nonfiction class. In the joint table strategy, separate tables are created for the superclass and subclasses. So the @ entity annotation is there in all three classes: Genre, fiction and nonfiction. Also, the @ table annotation is used on them to specify the names of the tables. So you can see, in the nonfiction class here, in the fiction class and the genre class. For the purpose of this demo, we are letting Hibernate generate the tables, but in a real application, you'll create the tables outside of Hibernate and then map them. So the…

Contents