-->
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: 0 to 1 relation
PostPosted: Tue Feb 15, 2005 4:56 pm 
Beginner
Beginner

Joined: Wed Jan 26, 2005 5:34 am
Posts: 41
Location: France, Paris
Hi,

how map a unidirectionnal '0 to 1' relation between 2 classes ?
I have one class A which can have (or not) an instance of B. So i have, 2 tables: A et B, and B have a foreign key from A. But i don't understand how map this model in hibernate (one-to-one, many-to-one with unique contraint ?)

Regards,

_________________
Vincent


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 5:07 pm 
Beginner
Beginner

Joined: Wed Jan 26, 2005 5:34 am
Posts: 41
Location: France, Paris
Indeed my problem is a bit more complex. I can't store the B data in A (with null columns), because i have a C entity which have a 0 to n relation with B (that's why i have a table for B).

So C has a bag of Bs, but i don't see how link A and B now :-/

_________________
Vincent


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 2:34 am 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
magic wrote:
Indeed my problem is a bit more complex. I can't store the B data in A (with null columns), because i have a C entity which have a 0 to n relation with B (that's why i have a table for B).

So C has a bag of Bs, but i don't see how link A and B now :-/


I would suggest not putting a foreign key in B at all, if both A and C can link to B. Use mapping tables.


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.