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 Unified Modeling Language (UML) diagram shows the relationship between the tables:
The following are the steps to create a new table:
- First, we create the Owner entity and repository in the domain package. The Owner entity and repository are created in a similar way to 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; ...