From the course: Creating Your First Spring Boot Microservice
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The JPA entities
From the course: Creating Your First Spring Boot Microservice
The JPA entities
- [Instructor] Now that we've established the business objects in the domain model, let's see the associated code. We're in a domain package, which is a new package that I've declared here. There is a class called Tour. As I said before this tutorial is for developers with previous knowledge of the Java Persistence API. For a quick overview of JPA check out the JPA chapter in my course Spring Data II. If you do know JPA then you will recognize the @Entity, @ID, @GeneratedValue, @Column, and @ManyToOne. These are annotations on this Java class and it's attributes. All the attributes in this class are present here, plus the generated ID field. In addition to the typical getters and setters, there is a constructor. This constructor is on line 50. It takes all the fields and initialize the attributes of those fields. I make my default constructor protected, so consumers of this class are only able to construct the…
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.