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 - JPA Tutorial
From the course: Java Persistence with JPA and Hibernate
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
-
-
-
-
-
-
-
-
(Locked)
One-to-one relationships8m 13s
-
@OneToMany and @ManyToOne annotations in a relationship8m 8s
-
(Locked)
Many-to-many relationships7m 29s
-
(Locked)
Inheritance9m 40s
-
(Locked)
More inheritance strategies9m 25s
-
(Locked)
Composition relationship11m 6s
-
(Locked)
Challenge: Art Class Management app, part 41m 58s
-
(Locked)
Solution: Art Class Management app, part 44m 41s
-
(Locked)
-
-
-