-->
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: many-to-one with Join Table
PostPosted: Mon Oct 27, 2003 8:50 am 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
Hi,

Can a many-to-one/one-to-many relationship between two classes be implemented with a separate join table?

The join table would look like:
Code:
many_id int not null,
one_id int not null unique,
primary key (many_id, one_id)

This would be useful if for some reason you didn't want to change the many side table to include a FK to the one side (i.e. there are very many rows but very few relationships, so for space efficiency), you are migrating from a many-to-many relationship, or you plan to migrate eventually to a many-to-many relationship.

many-to-many is unsatisfactory for this situation because on the many side class I want only a simple pointer to the single related object; I don't want to deal with a collection.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 8:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its not directly supported, but a workaround is to write a UserType.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 9:10 am 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
thanks for the reply.

I've created a JIRA feature request, please vote for it if you'd like to see this supported:

http://opensource.atlassian.com/project ... key=HB-425


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.