O'Reilly logo

Learning Spring Boot by Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining entities and repositories

When developing a data-oriented app, it's important to model the domain objects. For this application, we will manage Team and Teammate. The relationship between these two domain classes is defined as follows:

  • A Team can have zero or more Teammates
  • A Teammate is associated with zero or one Teams

Here is the definition for the Team class:

package learningspringboot; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; import java.util.ArrayList; import java.util.List; @Entity public class Team { @Id @GeneratedValue private Long id; private String name; @OneToMany(mappedBy = "team") private List<Teammate> members; private Team() { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required