4
I’m having trouble carrying out the method list of translations of the document, I’m not understanding the reason for the error, follows code:
Translation.java
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Translation {
    @Id
    @GeneratedValue
    private Long id;
    private String title;
    private String description;
    //muitas traduções para um documento
    @ManyToOne()
    @JoinColumn(name="id_document", referencedColumnName="id", nullable=false)
    private Document document;
}
Document.java
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Document {
    @Id
    @GeneratedValue
    private Long id;
    private String title;
    private String description;
    //um documento com muitas traduções
    @OneToMany(mappedBy="document")
    private Set<Translation> translations;
}
The mistake:
Exceptionhandlerexceptionresolver : Resolved Exception caused by Handler Execution: org.springframework.http.converter.Httpmessagenotwritableexception: Could not write JSON: Infinite recursion (Stackoverflowerror); nested Exception is com.fasterxml.Jackson.databind.Jsonmappingexception: Infinite recursion (Stackoverflowerror) (through Reference chain: model. Translation["Document"]->model.Document["Translations"]->org.hibernate.Collection.internal.Persistentset[0]->model.Translation["Document"]->cmodel.Document["Translations"]....
Thank you
I really found the problem in this link, thank you.
– Sabrina