This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Composite like relationship - Mapping Question

 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Varun, you could use this code below,



regards,
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but where do I specify that children are in COMPONENTTREE table, not in COMPONENT.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic