Next, we create a new table called owner that has a one-to-many relationship with the car table. The owner can own multiple cars, but a car can have only one owner. The following UML diagram shows the relationship between the tables:
The following are the steps for creating a new table:
- First, we create the Owner entity and repository in the domain package. The Owner entity and repository are created similarly to what we did with the Car class. The following is the source code of the Owner entity class and OwnerRepository:
// Owner.java package com.packt.cardatabase.domain; import javax.persistence.Entity; ...