This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman 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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Composite like relationship - Mapping Question" Watch "Composite like relationship - Mapping Question" New topic

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,

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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Composite like relationship - Mapping Question
It's not a secret anymore!