1、错误描述

org.hibernate.exception.GenericJDBCException: error executing work
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.coordinateWork(JdbcCoordinatorImpl.java:318)
	at org.hibernate.internal.SessionImpl.doWork(SessionImpl.java:2059)
	at org.hibernate.internal.SessionImpl.doReturningWork(SessionImpl.java:2055)
	at com.skycloud.oa.base.dao.impl.BaseDaoImpl.executeQuery(BaseDaoImpl.java:137)
	at com.skycloud.oa.task.dao.impl.TaskTimeDaoImpl.addTaskData(TaskTimeDaoImpl.java:59)
	at com.skycloud.oa.test.task.dao.TaskTimeDaoTest.testAddTaskData(TaskTimeDaoTest.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2318)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
	at com.skycloud.oa.base.dao.impl.BaseDaoImpl$2.execute(BaseDaoImpl.java:147)
	at com.skycloud.oa.base.dao.impl.BaseDaoImpl$2.execute(BaseDaoImpl.java:1)
	at org.hibernate.jdbc.WorkExecutor.executeReturningWork(WorkExecutor.java:72)
	at org.hibernate.internal.SessionImpl$3.accept(SessionImpl.java:2052)
	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.coordinateWork(JdbcCoordinatorImpl.java:313)
	... 33 more

2、错误原因

由于id在数据库表中是作为主键,但是在插入的过程中,没有给予数值,并且没有让其自增

3、解决办法

修改数据库表中的id,让其自增(在插入的过程中,不插入id数据时)

Caused by: java.sql.SQLException: Field 'id' doesn't have a default value的更多相关文章

  1. Hibernate报错:Caused by: java.sql.SQLException: Field 'ID' doesn't have a default value

    问题一: 报错如下: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assig ...

  2. 启动Spring boot报错:nested exception is java.sql.SQLException: Field 'id' doesn't have a default value

    先看具体日志: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with n ...

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

    ### The error may involve com.qingmu.core.dao.ad.ContentDao.insertSelective-Inline ### The error occ ...

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

    1:id 列要设置成自增,自动赋值 java.sql.SQLException: Field 'id' doesn't have a default value at com.mysql.jdbc.S ...

  5. 异常:Caused by: java.sql.SQLException: Field 'cust_id' doesn't have a default value

    异常: 由Java.q.L.SqLExpExt引起:字段“CuSTyID”没有默认值 Caused by: java.sql.SQLException: Field 'cust_id' doesn't ...

  6. java.sql.SQLException: Field 'id' doesn't have a default value异常

    在做mybatis插入的时候报了这个错误,百度了下,貌似是因为这个健没有设置值且不是自增类型的. java.sql.SQLException: Field 'id' doesn't have a de ...

  7. java.sql.SQLException: Field 'id' doesn't have a default value解决方案

    转自:https://blog.csdn.net/xinghuo0007/article/details/51810867 自增长:java.sql.SQLException: Field 'id' ...

  8. java.sql.SQLException: Field 'id' doesn't have a default value(用eclipse操作数据库时报了这种奇怪的错误)的原因与解决方法

    1.错误原因 由于id在数据库表中是作为主键,但是在插入的过程中,没有给予数值,并且没有让其自增 2.解决办法 修改数据库表中的id,让其自增(在插入的过程中,不插入id数据时)

  9. 使用Hibernate中出现了Caused by: java.sql.SQLException: Field 'gid' doesn't have a default value

    那是因为表中没有设置主键自动增长,只需要改变表中的主键设置为自动增长即可

随机推荐

  1. 面向切面编程之cglib代理方式

    思想: 和上一篇面向切面编程之手动JDK代理方式上的需求和开发模式一样.不同的是目标类没有接口,只有实现类,采用的是spring中提供的Enhancer类继承目标类实现的代理方式. 需要导入的jar包 ...

  2. spring之注解详解

    一.类级别注解 通用:@Component("id") Controller层:@Controller("id") Service层:@Service(&quo ...

  3. 所不为人知的Python装饰器

    装饰器可以说是Python中非常重要的特性之一.有些人要么从没使用过装饰器,要么就是对装饰器的使用一知半解.也有些人觉得装饰器很简单:"装饰器不就是那些把函数作为参数并输出一个函数的函数&q ...

  4. Jmockit之mock特性详解

    本文是Jmockit学习过程中,根据官网所列的工具特性进行解读. 1.调用次数约束(Invocation count constraints) 可以通过调用计数约束来指定预期和/或允许匹配给定期望的调 ...

  5. 玩转spring boot——国际化

    前言 在项目开发中,可能遇到国际化的问题,而支持国际化却是一件很头疼的事.但spring boot给出了一个非常理想和方便的方案. 一.准备工作 pom.xml: <?xml version=& ...

  6. linux中vim常用的快捷键

    移动光标的方法 h或者向左箭头:光标向左移动一个字符 j或者向下箭头:光标向下移动一个字符 k或者向上箭头:光标向上移动一个字符 i或者向右箭头:光标向右移动一个字符 Ctrl+f:屏幕向下移动一页[ ...

  7. POJ 2007 Scrambled Polygon [凸包 极角排序]

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 ...

  8. 《深入理解Java虚拟机》——垃圾收集器与内存分配策略

    GC需要完成: 哪些内存需要回收 什么时候回收 如何回收 如何确定对象不再使用 引用计数算法 给对象添加一个引用计数器,当有一个地方引用它时,计数器值进行加1操作:当引用失效时,计数器值进行减1操作: ...

  9. 「POJ2505」A multiplication game [博弈论]

    题目链接:http://poj.org/problem?id=2505 题目大意: 两个人轮流玩游戏,Stan先手,数字 p从1开始,Stan乘以一个2-9的数,然后Ollie再乘以一个2-9的数,直 ...

  10. python数据分析工具包(3)——matplotlib(一)

    前两篇文章简单介绍了科学计算Numpy的一些常用方法,还有一些其他内容,会在后面的实例中学习.下面介绍另一个模块--Matplotlib. Matplotlib是一个Python 2D绘图库,试图让复 ...