【发布时间】:2016-10-26 15:50:06
【问题描述】:
我已经通过 @JsonIdentityInfothrough 解决了 JSON 递归循环到 Baeldung 的博客1(谢谢)
但是现在,又出现了一个错误:
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();
}
}
这就是我在调试器中看到的:
请问有什么问题,为什么?
【问题讨论】:
-
只是IDE的错误(警告)