Hibernate ORM
  1. Hibernate ORM
  2. HHH-2660

Column names in generated SQL should be surrounded by the backtick character

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Rejected
    • Affects Version/s: 3.2.4.sp1
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      All 3.2 versions. All databases. I use MySQL.
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Column names in generated SQL statements should be surrounded by backtick character. This is necessary for column names that conflict with reserved words or functions. It is easily demonstrated by creating a table with a column name DIV and a column name GROUP. Hibernate currently generates invalid sql statements for accessing this table. "select DIV, GROUP from NEWTABLE" gives a syntax error. "select `DIV`, `GROUP` from NEWTABLE works as expected. It is only necessary to change two lines of code to fix this behavior.

      diff good\src\org\hibernate\sql\Insert.java bad\src\org\hibernate\sql\Insert.java
      91c91
      < buf.append( "`" + iter.next() + "`" );

      > buf.append( iter.next() );

      diff good\src\org\hibernate\sql\Update.java bad\src\org\hibernate\sql\Update.java
      143c143
      < buf.append( "`" + e.getKey() + "`" ).append( '=' ).append( e.getValue() );

      > buf.append( e.getKey() ).append( '=' ).append( e.getValue() );

        Activity

        Hide
        Steve Ebersole added a comment -

        Mmm, that or you could do that yourself in the mapping document as outlined in the docuemntation.

        Show
        Steve Ebersole added a comment - Mmm, that or you could do that yourself in the mapping document as outlined in the docuemntation.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development