[hibernate-issues] [Hibernate-JIRA] Updated: (ANN-676) Composite PK/FK and the alphabetical order of class names

Emmanuel Bernard (JIRA) noreply at atlassian.com
Wed Oct 31 15:09:30 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard updated ANN-676:
---------------------------------

    Fix Version/s:     (was: 3.3.1.beta1)
                   3.3.1

> Composite PK/FK and the alphabetical order of class names
> ---------------------------------------------------------
>
>                 Key: ANN-676
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-676
>             Project: Hibernate Annotations
>          Issue Type: Bug
>          Components: binder
>    Affects Versions: 3.3.0.ga
>         Environment: Hibernate Core 3.2.5.GA , Hibernate Annotations 3.3.0.GA, Sybase ASE 15
>            Reporter: Immo Heikkinen
>             Fix For: 3.3.1
>
>         Attachments: TestCaseFailure.zip, TestCaseOK.zip
>
>
> Original discussion on the user forum: http://forum.hibernate.org/viewtopic.php?t=980623
> I am having trouble with composite primary/foreign keys and sequence of classes with bidirectional one-to-many relationship between them. I am getting strange annotation exception with annotations that seem to be perfectly ok.
> My conclusion is that the name of classes need to be in alphabetical order, otherwise misleading exception about the number of columns is thrown.
> Attachment TestCaseOK.zip contains sequence of three entity classes A, B and C, with bi-directional one-to-many association between them. This mapping works fine.
> Attachment TestCaseFailure.zip contains the same classes, but B and C has been changed with each other (B has been renamed to C, and C has been renamed to B.) This mapping causes the following AnnotationException:
> Caused by: org.hibernate.AnnotationException: A Foreign key refering C from B has the wrong number of column. should be 1
> The reason for this seems to be the alphabetical order of the class names! Sequence A --> B --> C is fine but A --> C --> B is not.
> If you use @Table to define the database table names, it is the table names that need to be in alphabetical order.
> The same error can be also produced with @SecondaryTable in class/table that has composite PK. This case is more difficult since you cannot get rid of the exception, no matter how you name your classes or tables. I believe this is the same bug that appears in the comments of ANN-509 .

-- 
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