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.
Solution: Art Class Management app, part 4 - JPA Tutorial
From the course: Java Persistence with JPA and Hibernate
Solution: Art Class Management app, part 4
(upbeat music) - Here's my solution to this challenge. To implement a unidirectional one-to-one relationship between the art class and the teacher. In the art class entity, I've declared a field named teacher of type teacher. Then it's annotated with at one-to-one annotation. As the art class entity should be considered as the owner of the relationship. The @ join column annotation is also placed on the field with its name attributes set to teacher_id, which is the foreign key. To verify if the one-to-one relationship is established correctly, in the main class, in one-to-one relationship method, I create a new art class and teach Entity and Persist step. Now run it. You should get the SQL insert statements in the console. Next to implement a one to many and a minute to-one relationship between teacher and review, be the review entity as the owner of the relationship. Starting from the review class, I declare a field named teacher of type teacher. Then annotated with the @ManyToOne…
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)
-
-
-