Hi all,
I am using Hibernate Tools 3.2.4CR, Hibernate 3.2.5. GA and MySQL 5.1.
I succeeded to generate my *.hbm.xml, *.cfg.xml files, DB java classes for a MyISAM database.
Now that I am moving to InnoDB engine, I would like to have foreign keys be handled by Hibernate Tools.
I succeeded to generate the hibernate.cfg.xml by changing the database dialect to 'MySQL 5 (innodb)'.
Could someone tell me what is the right process to follow so that Hibernate Tools generate the proper Java classes for my InnoDB database?
(including proper handling of primary keys and foreign keys without having to edit manually the 'hibernate.reveng.xml')
Just for info, here is my SQL script:
-------------------- Begin MyDB.sql -------------------->
DROP TABLE IF EXISTS `Service`; CREATE TABLE IF NOT EXISTS `Service` ( `serviceId` int(10) unsigned NOT NULL auto_increment, `serviceName` enum('sms','alert','web','object','codelet','queue','vocal','barcode','videosecurity') NOT NULL, `operatorId` int(11) unsigned NOT NULL, PRIMARY KEY (`serviceId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11;
DROP TABLE IF EXISTS `Ip`; CREATE TABLE IF NOT EXISTS `Ip` ( `ipId` int(10) unsigned NOT NULL auto_increment, `ipv4` char(15) NOT NULL, `companyId` int(10) unsigned NOT NULL, `serviceId` int(10) unsigned NOT NULL, PRIMARY KEY (`ipId`), KEY `Index_CompanyId_ServiceId` (`companyId`,`serviceId`), KEY `Index_ServiceId` (`serviceId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11;
ALTER TABLE `Ip` ADD CONSTRAINT `ip_ibfk_2` FOREIGN KEY (`serviceId`) REFERENCES `service` (`serviceId`) ON DELETE CASCADE ON UPDATE CASCADE;
-------------------- End MyDB.sql -------------------->
Thank you for your help
|