-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: mapping choice
PostPosted: Thu May 01, 2008 1:32 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
Hi ,
I need help mapping a peculiar relation ship in hibernate.
In terms of database, I have a table(p_t) in which a column is associated with two tables. Each row in that table is either linked with one table(p) or the other(t).
How would I map this relationship. Would I need to use discriminator for that.?
In terms of xml schema I have an xml element for which there can be any number of two sub elements.
<parent>
<child1/>
<child2/>
<child1/>
</parent>

Any clues?.........


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 01, 2008 2:26 pm 
Beginner
Beginner

Joined: Wed Mar 05, 2008 4:57 am
Posts: 22
Location: Bangalore,India
With the data you have provided, choice of discriminator looks OK.

More comment can be provided if you furnish the classes/entities details.

_________________
Naresh Waswani
+91-9986461501


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 01, 2008 2:58 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
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.?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.