search

Home  >  Q&A  >  body text

java - SSH框架向数据库插入数据问题

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

高洛峰高洛峰2887 days ago359

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 18:01:26

    Set hibernate primary key strategy

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:01:26

    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.

    reply
    0
  • Cancelreply