When hbm2ddl.auto is set to update all tables and keys are checked to see if changes are needed. The algorith by which the names of the foreign keys are generated changed the last couple of versions. Now the update thinks the foreign keys don't exist and creates them again.
By changing findMatchingForeignKey in SchemaMigratorImpl to check the actual reference and fields that could be a lot smarter. So don't purely match on keyname but instead on the field and the referenced table with the referenced field.
Mysql 5.6, Linux
And also add some debug info to the steps done during updating the schema.
Replace the existing method findMatchingForeignKey() with the following code
Or the Java8 way:
And when the calling function is also changed (it does not use the returned key):
In 5.2.6 the class changed to AbstractSchemaMigrator.java
'gradle compile test' done and all tests pass. At least in folder hibernate-core. Did not test it for all but that doesn't seem necessary to me...