Hello, I'm in a project and I need to do bidirectional relationship between two entities, the relationship is @OneToMany
@ManyToOne
, so far so good. But I wonder if there is any way to do it without using DTO?
@Entity
public class Answer extends BasicForum {
@ManyToOne
@JsonIgnore
private Question question;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "answer")
private List<CommentAnswer> commentList;
@Entity
public class Question extends BasicForum{
private String title;
private Integer views;
@OneToMany(fetch= FetchType.LAZY, cascade= CascadeType.ALL, mappedBy = "question")
private List<Answer> answerList;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "question")
private List<CommentQuestion> commentList;
Thanks to everyone in the community.