Actually I am generating an xml document where there is a parent element which has two types of child elements.
<parent>
<child1/>
<child2/>
<child1/>
</parent>
There can be any number of child elements and in any order.
so there can be child2, child 2 ,child2 as the first three elements and the last might be of the type child1.
In order to represent this type of relationship in db , I have three tables parent , child1 and child2. Now to emulate the relationship , I need a join table which has one column which is a foreign key from the parent table.
And another column would be the id of the table itself.
And then there would be one column which would be either linked to child1 or child2 . So one row of that column might be linked with child1 and the second might be linked with child2. To distinguish this I have yet another column which would determine which child table is that particular row linked with.
Now how would I represent this relationship in hibernate.?
|