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.
Composition relationship - JPA Tutorial
From the course: Java Persistence with JPA and Hibernate
Composition relationship
- [Instructor] You may already know that the composition relationship in OOP, models has a whole part association, that is one class referring to another class, which is supposed to be the part, using an instance variable. It is generally recommended that composition should be used instead of inheritance wherever possible in plain Java classes. This is also valid for entity classes. At the same time, when working with entities, you should always keep in mind that your classes are mapped to database tables. Jakarta Persistence and Hibernate supports two ways to implement composition, association mapping and embedabbles. Association mapping is the most natural way of using composition in ORM. This is because the way it's done is similar in both the OO model and the relational model. Let's take this example. To implement composition using association mapping, start by running the mariadb-06_06.sql script. Let's run it. In the library, there are resources belonging to different fields…
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)
-
-
-