如baeldung blog中所述,我使用@JsonIdentityInfo解决问题(双向杰克逊无限递归)
@Entity
@Table(name = "Payment")
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "uuid")
public class Payment implements Serializable {
...
@ManyToOne
@JoinColumn(name = "registration", nullable = false)
private Registration registration;
...
}
@Entity
@Table(name="Registration")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
public class Registration implements Serializable {
...
@OneToMany(mappedBy="registration", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
private List<Payment> payment;
...
}
它有效,我没有递归错误,但JSON输出错误:
有什么问题?