This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Composite like relationship - Mapping Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Composite like relationship - Mapping Question" Watch "Composite like relationship - Mapping Question" New topic
Author

Composite like relationship - Mapping Question

Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
I have 2 tables - Component and ComponentTree.
Component is the master table for each component - whether parent or child. ComponentTree is parent-child relationship table (one to many).

for example:

Component Records:

componnent1, Parent Component
componnent2, Child Component
componnent3, Child Component


ComponentTree Records:

componnent1, component2
componnent1, component3


I have defined a single class



Since there is only one class 'Component', I am confused about associating children components to parent component in writing getBaseChildren() method.
Can someone help?



-Varun -
(My Blog) - Online Certifications - Webner Solutions
Angel Taveras
Ranch Hand

Joined: Nov 13, 2008
Posts: 84

Hello Varun, you could use this code below,



regards,
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Thanks but where do I specify that children are in COMPONENTTREE table, not in COMPONENT.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Composite like relationship - Mapping Question