java - Parent have list of child or Child have a parent reference -
I am preparing the database I am using the hibernate I have two types of class hierarchy
Episode 1:
class guardian {name of private long id private string; } Classroom Children {Personal Parents parentId; The name of the private string; }
Episode 2:
class guardian {name of private long id private string; Private listing & lt; Child & gt; children; } Class child {private string name; }
What is my better view of my question?
It depends on how you handle your parents' relationship and Want to use.
The case 1 is good if you want to access only the parents with the child and the owner of the child guardian.
Case 2 If you want to reach the list of children from parents then it is good, but there is no reference to parents in the individual child. This time the parents become the owner of the child and you can control the cascading as if you remove your parents, then you can remove all the children associated with it.
I personally like a case 3 which is a hybrid of both. / P>
Comments
Post a Comment