Hibernate ORM
  1. Hibernate ORM
  2. HHH-8520

Apply "global quote identifier" to HBM processing

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.4
    • Fix Version/s: 4.3.0.Beta5
    • Component/s: metamodel
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      Table name is quoted correctly, but column name is not quoted.

      Manual clone of HHH-6521 as unable to reopen or clone automatically.

      I am using PostgreSQLDialect, with PostgresSQL any unquoted name/identifier is converted to lowercase server side and then matched case sensitive against objects.

      If you have one or more uppercase characters you need to quote the name, just like you expect to need to quote if you use spaces in names/identifiers.

      hibernate.globally_quoted_identifiers=true

      Hibernate:
      select
      this_.userId as userId1_2_0_,
      this_.version as version2_2_0_,
      this_.whenCreated as whenCrea3_2_0_,
      this_.state as state4_2_0_,
      this_.whenStateChange as whenStat5_2_0_,
      this_.usernameSelectorId as username6_2_0_,
      this_.username as username7_2_0_,
      this_.passwordHash as password9_2_0_,
      this_.whenPasswordChange as whenPas12_2_0_,
      from
      "sec_UserCredential" this_
      where
      this_.usernameSelectorId=?
      and this_.username=?

        Issue Links

          Activity

          Hide
          Steve Ebersole added a comment -

          Going to need to see a test case

          Show
          Steve Ebersole added a comment - Going to need to see a test case
          Hide
          Darryl Miles added a comment -

          To clarify the use case in the ticket, no JPA annotations but HBM XML, I am not using any back-tick in my HBMs.

          My findings so far (while I try to get a local hibernate-orm git tree to build and unit-test so new unit tests can be added) :

          org.hibernate.mapping.Table#setName("`foo_My_table`") causes the Table instance to get quoted=true name="foo_My_table" (the back-tick quoting gets removed, I never configured the backticks in my HBM this got added by hibernate during startup)
          so when this is run through Table#getQuotedName(Dialect) the output is "\"foo_My_table\"" as the Dialect specific quotes are added back.

          org.hibernate.mapping.Column#setName("bar_my_column") causes the Column instance to get quoted=false name="bar_my_column" (quoting does not exist on input, my <property name="bar_my_column" column="bar_my_column"/> also does not contain backticks).
          so when this is run through Column#getQuotedName(Dialect) the output is "bar_my_column" and no quoting is introduced, this the SQL output does not contain quoting for column names

          so I am looking in the area of HbmBinder#bindColumns(...) at the time HBM parsing is done to check that the call into
          name = getObjectNameNormalizer().normalizeIdentifierQuoting( name );
          is done for the columnName parsed from the HBM XML. I do not think this is the case which is the bug here.

          Show
          Darryl Miles added a comment - To clarify the use case in the ticket, no JPA annotations but HBM XML, I am not using any back-tick in my HBMs. My findings so far (while I try to get a local hibernate-orm git tree to build and unit-test so new unit tests can be added) : org.hibernate.mapping.Table#setName("`foo_My_table`") causes the Table instance to get quoted=true name="foo_My_table" (the back-tick quoting gets removed, I never configured the backticks in my HBM this got added by hibernate during startup) so when this is run through Table#getQuotedName(Dialect) the output is "\"foo_My_table\"" as the Dialect specific quotes are added back. org.hibernate.mapping.Column#setName("bar_my_column") causes the Column instance to get quoted=false name="bar_my_column" (quoting does not exist on input, my <property name="bar_my_column" column="bar_my_column"/> also does not contain backticks). so when this is run through Column#getQuotedName(Dialect) the output is "bar_my_column" and no quoting is introduced, this the SQL output does not contain quoting for column names so I am looking in the area of HbmBinder#bindColumns(...) at the time HBM parsing is done to check that the call into name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); is done for the columnName parsed from the HBM XML. I do not think this is the case which is the bug here.
          Hide
          Steve Ebersole added a comment -

          You are asking for this to be applied to processing hbm.xml processing. That would actually be a new feature.

          Show
          Steve Ebersole added a comment - You are asking for this to be applied to processing hbm.xml processing. That would actually be a new feature.
          Hide
          Darryl Miles added a comment -

          Note the table name gets quoted in sympathy with the hibernate.properties setting (no quoting of table name exists in HBM).

          Show
          Darryl Miles added a comment - Note the table name gets quoted in sympathy with the hibernate.properties setting (no quoting of table name exists in HBM).

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development