In hibernate 5 Schema update re create foreign keys and unique keys against hibernate 4 DB

Description

When migrating from hibernate 4 to 5 and having
hibernate.hbm2ddl.auto to update
hibernate.implicit_naming_strategy to legacy-jpa
in the persistence.xml.

During the SchemaUpdate hibernate 5 recreate the databases foreign keys and unique keys when running against an existing database (hibernate 4 generated database).
Also the foreign key/unique key prefix are difference. Hibernate 4 uses UK_ or FK_ where as hibernate use UK or FK. Also the foreign key hash key has changed too.

see https://forums.hibernate.org/viewtopic.php?f=1&t=1042969 for more information.

The attachment foreignkeybefore.sql shows the schema after running against hibernate 4 and foreignkeyafter.sql show the same schema after upgrading to hibernate 5.
foreighkeyentities.zip contains the entities i used to generate the database

Environment

Wildfly 10 Final, Hibernate 5.0.7, Mysql 5.5

Status

Assignee

Unassigned

Reporter

Darrell Wu

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.7

Priority

Major