Some databases use upper-case column names. Thus, the schema migrator should use case-insensitive comparison, in case entity column definitions use lower-case column names.
Since this is currently not done, the migrator might try to re-create a foreign key and fail, if comparing the name of the foreign key also fails. This results in many exceptions that pollute the log and make it very hard to read.
org.hibernate.tool.schema.internal.AbstractSchemaMigrator.checkForExistingForeignKey: {code :java } Predicate<ColumnReferenceMapping> mappingPredicate = m -> { String existingReferencingColumn = m.getReferencingColumnMetadata().getColumnIdentifier().getText(); String existingReferencedTable = m.getReferencedColumnMetadata().getContainingTableInformation().getName().getTableName().getCanonicalName(); return referencingColumn.equals( existingReferencingColumn ) && referencedTable.equals( existingReferencedTable ); }; {code}
To fix this, {{existingReferencingColumn}} could be obtained just like {{existingReferencedTable}}: {code :java } String existingReferencingColumn = m.getReferencingColumnMetadata().getColumnIdentifier().getCanonicalName(); {code}
See test case in
[^HibernateMigrationBug.zip]
|
|