I am working on my school project and kind of replicating Stack Exchange site (project purpose only)
There is a table called Posts which might be a Question same as an Answer, based on PostTypeId. When it is a Question, it's column called AcceptedAnswerId is populated. However, there is no column listing all Answers for that Question.
The only relation between the Question and it's Answers is a column ParentId in the Answers. Meaning @ManyToOne
Now I need to get all Answers per that Question.
Any idea whether such thing is even possible?
So far, I've got something like this:
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "ParentId", referencedColumnName = "Id")
public Post getParentPost(){
return parentPost;
}
public void setParentPost(Post parentPost) {
this.parentPost = parentPost;
}