I'm having a Spring project, using JPA and Liquibase, I have a two-way relationship between two entities, I wonder if anyone has a solution to the infinite referral problem between the two? For example, I have a Question that has many answers, a answer has this question that has this answer and so it tends to infinity, I can not lose the bidirectionality so the annotation @IgnoreJson
would not be interesting. Follow my entities.
@Entity
@Table(name = "question")
public class Question extends BasicForum{
private String title;
private Integer views;
@OneToMany(cascade= CascadeType.ALL, mappedBy = "question")
private List<Answer> answerList;
@Entity
@Table(name = "answer")
public class Answer extends BasicForum {
@ManyToOne(cascade = CascadeType.ALL)
private Question question;