-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-many on the same TABLE
PostPosted: Thu Jan 03, 2008 8:01 am 
Newbie

Joined: Fri Dec 07, 2007 6:34 am
Posts: 5
Hi
I have a table in which I have two columns:

Parent_CD
Child_CD


And Parent_CD can have more than 1 Child_CD under it.
So if I want to know what are the Child_CD under a particular Parent_CD, how should I proceed?
Should I do one to many relationship on it but how can I implement it on the same table?

I am using JPA annotations for mapping.
Does JPA has any provisions for it?

Help me out.


Top
 Profile  
 
 Post subject: solution
PostPosted: Thu Jan 03, 2008 12:07 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
See here

http://www.hibernate.org/86.html

and here

http://lykke.wordpress.com/2006/08/04/s ... hibernate/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 07, 2008 5:01 am 
Newbie

Joined: Fri Dec 07, 2007 6:34 am
Posts: 5
here Child_CD is a unique key and Parent_CD is just another column.
Table has its own id column.

one-to-many is applied when we have a primary key and some other column references it as a foreign key.

Please help, what should I do?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 07, 2008 9:09 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Not necessarily true: one-to-many might be implemented in several ways table-wise (an extra column on the child table, a relation table).

Don't think that each type of relationship has only one table representation.

_________________
Gonzalo Díaz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.