I have resolved JSON recursive loop with @JsonIdentityInfo
through to Baeldung's blog1 (Thanks)
But now, another error occurs :
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate com.mezoo.tdc.model.Payment.toString()
Here my Registration object :
@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();
}
}
Now, Payment object :
@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();
}
}
This is, what I see in debugger :
Please, what is wrong and why ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…