Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-4088

HHH-5103 -- Specifying the referencedColumnName in a @JoinColumn with backtics like `uid` fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • EAP_EWP 5.1.0, 4.3.0.GA_CP09
    • 4.3.0.GA_CP07, EAP 5.0.1.CR1, EAP 5.0.1.CR2, EAP 5.0.1
    • Hibernate
    • None
    • EAP 4.3 with Hibernate commons annotations 3.0.0.GA and Hibernate core 3.2.4.sp1.cp09

    • Release Notes
    • Hide

      Do not specify the reference referencedColumnName as long as it refers to the primary key as Hibernate will automatically choose the primary key

      Show
      Do not specify the reference referencedColumnName as long as it refers to the primary key as Hibernate will automatically choose the primary key
    • Hide
      When a column name was defined in backticks (`), <varname>@JoinTable</varname> and
      <varname>@JoinColumn</varname> mappings failed with <exceptionname>AnnotationException</exceptionname>
      when the column name with backticks was referenced. Hibernate now compares the
      <literal>referencedColumnName</literal> with the column's quote name rather than the
      table column's name.
      Show
      When a column name was defined in backticks (`), <varname>@JoinTable</varname> and <varname>@JoinColumn</varname> mappings failed with <exceptionname>AnnotationException</exceptionname> when the column name with backticks was referenced. Hibernate now compares the <literal>referencedColumnName</literal> with the column's quote name rather than the table column's name.
    • Documented as Resolved Issue

    Description

      [is related to http://opensource.atlassian.com/projects/hibernate/browse/HHH-5103]

      Given a column with a defined name in backtics like so
      @Id
      @GeneratedValue
      @Column(name = "`uid`")
      private long userid;

      A @JoinTable/@JoinColumn mapping fails if specifically referencing the backtic name, instead one must leave off the backtics so the discovery can happen based on the pk.

      This fails:
      @JoinTable(name = "SYS_GROUPS_USERS", joinColumns = @JoinColumn(name = "USERID", referencedColumnName = "`uid`"), inverseJoinColumns = @JoinColumn(name = "GROUPID", referencedColumnName = "GROUPID"))

      While this works:
      @ManyToMany(fetch = FetchType.LAZY)
      @JoinTable(name = "SYS_GROUPS_USERS", joinColumns = @JoinColumn(name = "USERID"), inverseJoinColumns = @JoinColumn(name = "GROUPID"))

      The exception is
      Caused by: org.hibernate.AnnotationException: Column name uid of org.domain.seam202.entity.SysUserOrm not found in JoinColumns.referencedColumnName
      at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:321)
      at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1322)
      at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1161)
      at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:600)
      at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
      at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
      at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:323)
      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
      at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1225)
      at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:159)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)

      Attachments

        Activity

          People

            rrajasek@redhat.com Rajesh Rajasekaran
            sjmenden_jira Samuel Mendenhall (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: