J'ai résolu boucle récursive JSON avec @JsonIdentityInfo
par le blog de Baeldung 1 (la Merci)Spring JPA bidirectionnel ne peut pas évaluer toString
Mais maintenant, une autre erreur se produit:
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate com.mezoo.tdc.model.Payment.toString()
Voici mon objet d'enregistrement:
@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();
}
}
maintenant, objet de paiement:
@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();
}
}
C'est, ce que je vois Débogueur:
S'il vous plaît, ce qui est faux et pourquoi?
Ce n'est qu'une erreur d'un IDE (avertissement) – Mezoo