I have two entities with one to many relationships:
public class User {
@Id
@GeneratedValue
private Long id;
private String username;
private String phoneNumber;
private Timestamp creationDate;
@OneToMany(mappedBy = "user")
private List<Role> roles;
}
public class Role {
@Id
@GeneratedValue
private long id;
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;
}
but when I call get method to load user information I can see in the log file that additional query to retrieve user's roles also called. How can I prevent it with spring data rest?