User
@Document(collection = "users")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class User {
@Id
private String id;
private String name;
private String email;
public User(String id, String name, String email) {
this.id = id;
this.name = name;
this.email = email;
}
//Quando formos buscar um Usuário, não é para carregar os seus posts.
//Só carregamos os posts se chamarmos eles.
@DBRef(lazy = true).
@Setter(AccessLevel.NONE)
public List<Post> posts = new ArrayList<>();
}Atualizado