A schema-update on a database-schema created with Hibernate v4 (using a different FK-naming) fails with Hibernate v5.2.12, because the latter attempts to create the all foreign-key constraints again, although they exist (some RDBMS allow this, other reject it (eg. SQLServer, if the FK has cascade-options)). A look into code (org.hibernate.tool.schema.internal.AbstractSchemaMigrator.checkForExistingForeignKey()) revealed, that the table-name-comparison during the recognition of existing constraints is erroneous: a canonical name (Identifier.getCanonicalName(); lowercase, if not quoted) is compared with a non-canonical name (in my use-case an uppercase name). Comparing the canonical names (or better using Identifier.equals()) does, however, not completely fix the problem. It will work for unquoted names, but not for quoted ones, because the name of a org.hibernate.tool.schema.extract.spi.TableInformation is currently considered always as unqouted (s. org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.extractTableName()). Here should eventually the global quoting-option ("hibernate.globally_quoted_identifiers") be considered, in order to be able to compare the names correctly. |