Caused by: java.sql.SQLException: Field 'id' doesn't have a default value

来源:互联网 发布:人机界面触摸屏编程 编辑:程序博客网 时间:2024/04/29 21:24

Because:

In hdm xml:


<generator class="native"></generator>

 


In department table:

+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| id        | int(11)     | NO   | PRI | NULL    |       |
| name      | varchar(20) | NO   |     | NULL    |       |
| depart_id | int(11)     | NO   | MUL | NULL    |       |
+-----------+-------------+------+-----+---------+-------+

id is not auto-increment

Action:

 alter table department modify column id int NOT NULL AUTO_INCREMENT;

insert successfully.

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ejblover/archive/2010/01/21/5221791.aspx

原创粉丝点击