我已经通过Baeldung博客1解决了JSON递归循环问题,使用了
但是现在,又出现了另一个错误:
现在,支付对象:
@JsonIdentityInfo
。谢谢。但是现在,又出现了另一个错误:
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate com.mezoo.tdc.model.Payment.toString()
这是我的注册对象:
@Entity
@Table(name="Registration")
@JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
public class Registration implements Serializable {
/*some private variables..*/
// Bidirectional relationship
@OneToMany(mappedBy="registration", cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, fetch = FetchType.LAZY)
private List<Payment> payment;
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("payment", payment)
.toString();
}
}
现在,支付对象:
@Entity
@Table(name="Payment")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
public class Payment implements Serializable {
@ManyToOne
@JoinColumn(name = "registration")
private Registration registration;
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("registration", registration)
.toString();
}
}
这是我在调试器中看到的:
请问,出了什么问题?为什么?