-->
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.  [ 6 posts ] 
Author Message
 Post subject: Unidirectional one-to-many association
PostPosted: Mon Sep 19, 2005 5:43 am 
Newbie

Joined: Mon Sep 19, 2005 5:32 am
Posts: 2
Hi,

I have a question about the Hibernate Reference Documentation version 3.0.5. In the Chapter 8. Association Mappings it says:

Quote:
A unidirectional one-to-many association on a foreign key is a very unusual case, and is not really recommended. [...] We think it's better to use a join table for this kind of association. [...] A unidirectional one-to-many association on a join table is much preferred.


I need to map such an association, and it seems more natural to me to use a foreign key than a join table.
Could someone explain why the documentation says not to do so?

Thanks,

Amélie

Hibernate version:
3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 1:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The join table keep your second table free of any "polluting" FK. If you want to use a join column, feel free.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 2:30 am 
Newbie

Joined: Mon Sep 19, 2005 5:32 am
Posts: 2
Thanks for the answer.

I'm not sure the FK is so "polluting" in our case.
What about performance issues? Isn't a join table less efficient for performance than just a FK?

I think it would be useful if the reference documentation could explain the pros and cons of each of the options, instead of just saying it is "not recommended".

Amélie


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 5:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
it requires an extra join, wich shouldn't be too costy.
If we put an explaination, we'll find a DBA who disagree with us, then we'll have to explain the explaination and so on ;-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: remove it
PostPosted: Mon Jul 31, 2006 12:40 pm 
Newbie

Joined: Mon Jul 31, 2006 12:24 pm
Posts: 1
Quote:
If we put an explaination, we'll find a DBA who disagree with us, then we'll have to explain the explaination and so on ;-)

Agree or disagree, the fact of the matter is that there is an opinion written into the documentation that causes the reader to wonder if there is some type of technical/performance reason for it being there. That statement sent the original poster, me, and probably countless others on a wild-goose chase.

It should be removed.


Top
 Profile  
 
 Post subject: Re: remove it
PostPosted: Mon Apr 23, 2007 5:17 pm 
Newbie

Joined: Fri Apr 15, 2005 7:52 pm
Posts: 13
I agree with the previous comment. While migrating to annotations I spent many hours on this topic simply to find out that this is a totally debatable statement. People might get scared and needlessly try to update their whole schema to "comply" with that statement. Hibernate is an awesome product, but sometimes the docs are a bit too opinionated ;)


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