Hibernate + mySQL +代码生成器

时间:2014-12-04 12:45:23

标签: java mysql hibernate mapping

我在Eclipse中使用Hibernate Code Generator插件 当我将MySql结构导出到带有注释的.java文件但在文件中没有映射注释时 为什么呢?

SQL

CREATE TABLE IF NOT EXISTS `car` (
  `serialNumber` varchar(255) NOT NULL,
  `cc` int(11) NOT NULL,
  `l100` double DEFAULT NULL,
  `nameCar` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`serialNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `driver` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `age` int(11) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

CREATE TABLE IF NOT EXISTS `have` (
  `driver_id` int(11) NOT NULL,
  `car_serialNumber` varchar(255) NOT NULL,
  PRIMARY KEY (`driver_id`,`car_serialNumber`),
  KEY `fk_driver_has_car_car1_idx` (`car_serialNumber`),
  KEY `fk_driver_has_car_driver_idx` (`driver_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `have`
  ADD CONSTRAINT `fk_driver_has_car_driver` FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `fk_driver_has_car_car1` FOREIGN KEY (`car_serialNumber`) REFERENCES `car` (`serialNumber`) ON DELETE NO ACTION ON UPDATE NO ACTION;

如你所见,"有"是映射表

0 个答案:

没有答案