-->
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 One with association table
PostPosted: Mon Mar 22, 2004 9:30 pm 
Newbie

Joined: Mon Mar 22, 2004 9:19 pm
Posts: 2
I have the following situation in my schema:

There is a User table. Users can belong to just one Group. There is no need for navigating from Groups to Users. These two tables are related by a third table: UserGroup. In this third table, the FK column from User is the PK.

Is it possible to _naturally_ - no association class or many to many - map this relationship with Hibernate? If not, what would be the not-that-ugly approach? In case it's not possible, can someone please tell me where should i look for in the sources in order to implement this feature?

Tnx,
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 8:54 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
Hi,
Your db design seems to indicate that it is not 1:1, so why would you try to use 1:1 in your object model?

Sounds like using many-many would be the way to go.

James


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 9:07 am 
Newbie

Joined: Mon Mar 22, 2004 9:19 pm
Posts: 2
Not really. USER_ID is the PK in UserGroup. So, a User belongs to zero or one Group in this case. I don't need to navigate this relationship from Group to User, but there are other cases in this database in which there are truly one-to-one relationships - like, in table AB one key is the PK from table A and the one from table B is an AK. I'd like to know the best way to map this situation with Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 9:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There is no support for one-to-one across an association table. You will have to look at mapping to the associate table and possible hide these details behind some service methods.


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.