From the course: Spring Cloud GCP: Setting Up a Cloud SQL Database

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution: Adding a new entity

Solution: Adding a new entity

From the course: Spring Cloud GCP: Setting Up a Cloud SQL Database

Start my 1-month free trial

Solution: Adding a new entity

(upbeat music) - (Instructor) We are going to discuss the solution for the challenge of adding an Owner Entity to our API in this video. For the first step, we want to define what this new owner object will look like. To save time, I already have a POJO, or Plain Old Java Object for our owner defined already, With the fields constructor, and getter and setter methods. Now that of these fields are defined, we need to let JPA or the Java Persistence API, know that this is an entity for a database in the owner table. We can do that by adding the @entity annotation at the top of our class. We also need to tell JPA, what field to use for the ID With this entity. We can do that by adding the @ID annotation above our ID field. I also want JPA to automatically generate this ID for me, which I can do with the generated value annotation. And the generation type .auto as the strategy. Next, we want to create an owner…

Contents