I encounter the following problem with Hibernate and foreign keys:
When I first deploy my web application, Hibernate was configured with this parameters (among many others):
databasePlatform
set to "generic" (not engine specific) dialectorg.hibernate.dialect.MySQLDialect
.hibernate.hbm2ddl.auto
set toupdate
As the default engine was MyISAM
, Hibernate logically created MyISAM
tables with indexes, ignoring creation foreign keys (since MyISAM
doesn't support such constraints).
Now that I want to migrate every tables to InnoDB
, I would like Hibernate to automatically create missing foreign keys. Unfortunately, it looks like Hibernate is just looking for the index :
- If the index exists, Hibernate will not create the corresponding foreign key;
- If I drop the index, Hibernate will create both index and foreign key.
Since I don't want to drop every index in my schema, do you know a way to tell Hibernate to create the foreign key even if the index is created?
Thank you.