Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a

Posted 随笔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a相关的知识,希望对你有一定的参考价值。

异常信息

### Error updating database.  Cause: java.sql.BatchUpdateException: Field ‘id‘ doesn‘t have a default value
Query is: INSERT INTO
         `test`.`order` 
        (
         
         `order`.`code`,
         `order`.`create_date`,
         `order`.`status`,
        )
        VALUES (
         
         ?,

                                                                ?,

原因 

数据库表设计时候id没有加自动增长

mybatis添加后执行了查询id 而报错

<selectKey resultType="long"
                   keyProperty="id"
                   order="AFTER">
            SELECT
            LAST_INSERT_ID()
        </selectKey>

 解决方法

mysql数据库的id设为自增列

以上是关于Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a的主要内容,如果未能解决你的问题,请参考以下文章

eclipse关闭Updating Error Reporting Database

eclipse关闭Updating Error Reporting Database

org.springframework.jdbc.BadSqlGrammarException: Error updating database

### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 必须声明标量变量 "

mybatis的报错____3Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error

mybatis报Error updating database. Cause: java.lang.IllegalArgumentException: invalid comparison: jav