-->
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: Question regarding one-to-many relationship
PostPosted: Sat Aug 06, 2005 8:58 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
I've a class A which has one to many relationship with class B. Each row in class B need not be unique and hence need not have a primary key, but should have A.id like below

class A {
private Long id;
Set<B> bs;
}

class B {
private Long aId;
private String data;
}

aId is the foreign key from A. Is it possible to have such relationship without having primary key in class B? class A --> Table A and class B---> Table B. Having primary key in class B is not going to help as each entry need not be unique. The only query that we'll run is to find all the entries in B where aId=XXXX.


Could please someone let me know if this is possible in hibernate?

Thanks for any input in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 11:28 pm 
Newbie

Joined: Fri Jan 07, 2005 5:46 pm
Posts: 19
Mapped classes must declare the primary key column of the database table. (6.1.4. id in the reference docs). If you want to use Hibernate, your tables need a primary key.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 07, 2005 12:47 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks a5sk4s for your response.


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.