From the course: Java Persistence with JPA
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Demo: Annotating a one-to-one relationship - Java Tutorial
From the course: Java Persistence with JPA
Demo: Annotating a one-to-one relationship
- [Instructor] Now let's open the code to see the one-to-one relationship modeled in Java using the at one-to-one annotation. I'm navigated to the employee class in IntelliJ. Let's scroll down to line 36 and notice here, you'll see the OneToOne annotation with mappedBy. mappedBy signals hibernate to use the EmployeeProfile's employee field to map the profile to an employee. Now, let's navigate to EmployeeProfile, and let's scroll down to line 26. Here on line 26, notice, there's also a OneToOne annotation on this employee field. This is how the mapping works from the Employee object. This employee field in EmployeeProfile makes the mapping happen. Now, let's see how this mapping is modeled in the Postgres database. Let's navigate to pgAdmin. Remember, the employee entity is mapped to a table name employee. So let's see what's in our Employee's database. We have one entity, Mary Doe, and let's make a note of her…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
What are entity relationships?3m 34s
-
(Locked)
Annotating a one-to-one relationship2m 18s
-
(Locked)
Demo: Annotating a one-to-one relationship2m 24s
-
(Locked)
Annotating a one-to-many relationship2m 34s
-
(Locked)
Demo: Annotating a one-to-many relationship3m 26s
-
(Locked)
Annotating a many-to-one relationship1m 14s
-
(Locked)
Demo: Annotating a many-to-one relationship1m 50s
-
(Locked)
Annotating a many-to-many relationship1m 40s
-
(Locked)
Demo: Annotating a many-to-many relationship3m 11s
-
(Locked)
Utilizing inheritance mapping strategies4m 26s
-
(Locked)
Demo: Utilizing inheritance mapping strategies6m 7s
-
(Locked)
Challenge: Implement a many-to-many relationship53s
-
(Locked)
Solution: Implement a many-to-many relationship2m 30s
-
-
-
-