I have following table:
FOLDER[
id int,
name varchar2(10),
parent_folder_id int
]
I would like to have Folder class to have parent-child relationship.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe the correct mapping would be:
The
@OneToOnewould work only if each parent had at most one child, the above code works for the more general case, when a parent can have many children. Also, I’m omitting get/set methods for simplicity’s sake.