给定以下两个实体:
@Entity
public class Goal {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String description;
private BigDecimal amount;
private String email;
private String supervisorEmail;
private LocalDateTime deadline;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private PaymentPurpose purpose;
@Enumerated(EnumType.STRING)
private GoalStatus status;
@ManyToOne(cascade = CascadeType.ALL)
private Person person;
//getters and setters
}
和
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String firstName;
private String lastName;
private String email;
@OneToMany(mappedBy = "person")
private List<Goal> goals;
//getters and setters
}
当我goalRepository.findAll()在插入带有DummyGoal的Dummy后打电话时Person,我得到了永无止境的递归循环。添加@JsonIgnore到goal列表中Person并没有帮助。我也试过了@JsonIgnoreProperties。我想念什么?
相关分类