© Anghel Leonard 2020
A. LeonardSpring Boot Persistence Best Practiceshttps://doi.org/10.1007/978-1-4842-5626-8_15

15. Inheritance

Anghel Leonard1 
(1)
Banesti, Romania
 

Item 138: How to Efficiently Use Single Table Inheritance

The single table inheritance is the default JPA strategy. Conforming to this strategy, all the classes in an inheritance hierarchy are represented via a single table in the database.

Consider the inheritance hierarchy given in Figure 15-1.
../images/487471_1_En_15_Chapter/487471_1_En_15_Fig1_HTML.jpg
Figure 15-1

Single table inheritance Domain Model

Between Author and Book there is a bidirectional lazy @OneToMany association. The Author entity can be seen as the root class, since without authors ...

Get Spring Boot Persistence Best Practices: Optimize Java Persistence Performance in Spring Boot Applications 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.