Thanks for the tip,
After some testing i have figured out that the Foreign key name between hibernate 4 and 5 are different.
hibernate 4 uses "FK_<some hash>
while
hibernate 5 uses "FK<some other hash>.
It also looks like when hibernate does the schema generation hibernate 4 checks for existing foreign keys and indexes as when i use hibernate 4 over a hibernate 5 generated database i didn't get any FK_<some hash> foreign keys or indexes generated in my database as i expected.
Where as when i ran hibernate 5 over a hibernate 4 generated database interesting i got FK<some other hash> foreign keys generated but no extra indexes.
So i ended up with extra Foreign key contraints as shown below
Code:
CREATE TABLE `OP_ACCESS_TOKEN` (
`OBJECT_ID` bigint(20) NOT NULL,
`MODIFIED_BY` varchar(31) NOT NULL,
`MODIFIED_DATE` datetime NOT NULL,
`REC_STATUS` varchar(1) NOT NULL,
`CONSUMER_KEY` varchar(64) NOT NULL,
`CONSUMER_SECRET` varchar(64) NOT NULL,
`AGENCY_ID` bigint(20) NOT NULL,
`SERVICE_PROVIDER_ID` bigint(20) NOT NULL,
PRIMARY KEY (`OBJECT_ID`),
KEY `FK_e45y19tatyq1jxttxw7gne8c9` (`AGENCY_ID`),
KEY `FK_oy2qxqkloypnv1x37m4hb3qiw` (`SERVICE_PROVIDER_ID`),
CONSTRAINT `FKgkgpjour1g05greiw7x0x6xkm` FOREIGN KEY (`SERVICE_PROVIDER_ID`) REFERENCES `OP_SERVICE_PROVIDER` (`OBJECT_ID`),
CONSTRAINT `FK58gxc0d3nlgdfiodvenu1fmao` FOREIGN KEY (`AGENCY_ID`) REFERENCES `OP_AGENCY` (`OBJECT_ID`),
CONSTRAINT `FK_e45y19tatyq1jxttxw7gne8c9` FOREIGN KEY (`AGENCY_ID`) REFERENCES `OP_AGENCY` (`OBJECT_ID`),
CONSTRAINT `FK_oy2qxqkloypnv1x37m4hb3qiw` FOREIGN KEY (`SERVICE_PROVIDER_ID`) REFERENCES `OP_SERVICE_PROVIDER` (`OBJECT_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
it looks like hibernate 5 does a name check instead of a key contraint check when determining to create Foreign keys.
Does this sound right?
i guess i should rename our FK and indexes