-->
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.  [ 2 posts ] 
Author Message
 Post subject: Relationships/FKs to non-PK columns
PostPosted: Mon May 02, 2011 5:47 am 
Beginner
Beginner

Joined: Thu May 20, 2010 12:31 pm
Posts: 28
I just found out that officially relationships/foreign keys to non-primary key columns aren't supported by JPA. See here:

http://stackoverflow.com/questions/5818 ... ey-columns

Why do such relationships map in Hibernate nontheless (only in JPA 1.0 syntax as in the example posted there)??

It appears that Hibernate just maps the columns naively, which I think is a good thing, but I'd like to know explicitly. Is it coincidence? Is it intended? Is there anything in the docs where it supports this scenario?

Karsten


Top
 Profile  
 
 Post subject: Re: Relationships/FKs to non-PK columns
PostPosted: Mon May 02, 2011 6:54 am 
Beginner
Beginner

Joined: Thu May 20, 2010 12:31 pm
Posts: 28
The only thing I found in the docs is this:

http://docs.jboss.org/hibernate/stable/ ... ssociation

Quote:
It has one more parameters named referencedColumnName. This parameter declares the column in the targeted entity that will be used to the join. Note that when using referencedColumnName to a non primary key column, the associated class has to be Serializable. Also note that the referencedColumnName to a non primary key column has to be mapped to a property having a single column (other cases might not work).

So Hibernate basically supports these relationships with limitations to single-column FKs.

Karsten


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