java - SSH框架向数据库插入数据问题
高洛峰
高洛峰 2017-04-17 17:59:26
0
2
360

SSH执行向数据库插入数据时 遇到自增的ID提示一定要填写 但自己在数据库操作的时候不需要填写 为什么 怎样设置ID 在代码中实现插入数据不需要填写ID ID是主键

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
黄舟

Set hibernate primary key strategy

Peter_Zhu

When you create the table, set the primary key to auto-increment. As follows:

CREATE TABLE `order` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=177940 DEFAULT CHARSET=utf8 COMMENT='工单主表';

AUTO_INCREMENT above is to set the primary key to auto-increment mode.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template