Uploaded image for project: 'Hibernate ORM'
  1. HHH-12106

Database name not quoted at schema update

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.12
    • Fix Version/s: 5.3.0.Beta1
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Microsoft SQL-Server with a database which contains a hyphen in the name
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • backPortable:
      Backport?
    • Last commented by a user?:
      true
    • Sprint:

      Description

      The database schema update fails on a Microsoft SQL-Server 2008 (and probably newer versions and other database types too) if the database name contains a hyphen. In that case the SQL-Server expects the database name part inside the full qualified table name to be quoted. Example:
      Does not work:
      alter table serie-m.paul.TEST add [C1] varchar(255)
      Works:
      alter table "serie-m".paul.TEST add [C1] varchar(255)

      Setting property hibernate.globally_quoted_identifiers=true does not help, at schema update the code in org.hibernate.mapping.Table#sqlAlterStrings (line 450) still gets the qualified table name wrong, because TableInformationImp#tableName provides it without quotes, likely because its' identifierHelper (which has NormalizingIdentifierHelperImpl#globallyQuoteIdentifiers = true) is not used at #getName().

      Attached test case can be used to reproduce the problem, after adapting the settings to connect to a Microsoft SQL-Server with a hyphen in the database name.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: