File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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 agree. Here's the link:
subject: Composite like relationship - Mapping Question
Similar Threads
Hibernate one-to-many relationship insert
what changes should i made in save method in one-to-many relationships
Error when saving relationship
Cascading update problem
retrieving object hierarchy - many-to-one?