[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-590) Alphabetical order issue when @ManyToOne is used in PrimaryKey and explicit referencedColumnName are used

Li Ho (JIRA) noreply at atlassian.com
Thu Aug 30 21:45:23 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27984 ] 

Li Ho commented on ANN-590:
---------------------------

We ran into a similar issue.  We are using a single-table inheritance model with embedded composite keys.  In our case, we rename a join column in the superclass that the subclasses refer to.

We were getting intermittent failures because multiple classes mapped to the same table were not being ordered correctly inside AnnotationConfiguration.processFkSecondPassInOrder().  The Comparator implementation will order based on table name, but since we were using single-table inheritance, the ordering ends up being based on hashCode() which is random.

We need it to order the processing so that the superclass gets processed before subclasses.

The code in this section is complicated by the need to support both single-table and table-per-subclass inheritance models.  

We have a temporary fix/hack, but we are currently considering changing our mapping strategy in order to workaround this issue.


> Alphabetical order issue when @ManyToOne is used in PrimaryKey and explicit referencedColumnName are used
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: ANN-590
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-590
>             Project: Hibernate Annotations
>          Issue Type: Bug
>          Components: binder
>    Affects Versions: 3.2.1
>            Reporter: Eddie Man
>            Priority: Critical
>         Attachments: src.zip
>
>
> Problem:
> When I run the test.Main in the attachment, an mapping exception thrown while passing the annotation:
> Exception in thread "main" org.hibernate.MappingException: Unable to find column with logical name: customerID in ShoppingBasket
>    at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:383)
>    at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:88)
>    at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
>    at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
>    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
>    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
>    at test.Main.main(Main.java:19)
> But when I change the table name of ShoppingBaskets to "Basket", then the problem solved.

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