Mismatched order of composite keys in joins
-------------------------------------------
Key: HBX-934
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-934
Project: Hibernate Tools
Issue Type: Bug
Components: reverse-engineer
Affects Versions: 3.2beta9
Reporter: Anthony Patricio
http://opensource.atlassian.com/projects/hibernate/browse/ANN-571
According to the JPA specification (p. 169) if there are multiple @JoinColumn annotations
specified within an @JoinColumns annotation then both name and referencedColumnName
attributes must be used:
"If there is more than one join column, a JoinColumn annotation must be specified for
each join column
using the JoinColumns annotation. Both the name and the referencedColumnName elements
must be specified in each such JoinColumn annotation."
Right now, if I leave off the referencedColumnName everything appears to work but I get
some random SQL. For instance, say I have two tables TABLE1 and TABLE2 and they are joined
on the columns ID and TYPE, sometimes I get the right join condition:
TABLE1.ID = TABLE2.ID AND TABLE1.TYPE = TABLE2.TYPE
but sometimes I get:
TABLE1.ID = TABLE2.TYPE AND TABLE1.TYPE = TABLE2.ID
Adding the referencedColumnName makes that issue go away.
Emmanuel thinks the easiest way to solve this is to explicit the column names, as the spec
recommend.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira