[hibernate-issues] [Hibernate-JIRA] Created: (HCANN-31) Order of @JoinColumn annotations

Rich McLaughlin (JIRA) noreply at atlassian.com
Tue Dec 7 11:23:13 EST 2010


Order of @JoinColumn annotations
--------------------------------

                 Key: HCANN-31
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-31
             Project: Hibernate Commons Annotations
          Issue Type: Bug
            Reporter: Rich McLaughlin


I have two entities that I'm trying to join on 3 columns.  For some reason, the order of the @JoinColumn annotations affects the SQL that get produced.  I double-check my classes and all the columns are named and annotated correctly.

This annotation:
@JoinColumns({
	@JoinColumn (name = "ATTR_1"),
	@JoinColumn (name = "ATTR_2"),
	@JoinColumn (name = "ATTR_3")
})

produces this SQL:
        on this_.ATTR_1=othertable_.ATTR_2
        and this_.ATTR_2=othertable_.ATTR_1
        and this_.ATTR_3=othertable_.ATTR_3

But when I switch the annotation:
@JoinColumns({
	@JoinColumn (name = "ATTR_2"),
	@JoinColumn (name = "ATTR_1"),
	@JoinColumn (name = "ATTR_3")
})

Then it works
        on this_.ATTR_1=othertable_.ATTR_1
        and this_.ATTR_2=othertable_.ATTR_2
        and this_.ATTR_3=othertable_.ATTR_3

Any ideas?

Thanks!


-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list