[bug] Field 'id' doesn't have a default value
2016-01-06 16:46
423 查看
在使用 spring + Hibernate + JPA 连接 Mysql时,报错如下:
bug:Field 'id' doesn't have a default value
原因是因为自己粗心,主键id并没有自增,没有勾选:AUTO_INCREMENT
代码:
public static void main(String[] args) {
ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:beans.xml");
RequestLogService service = (RequestLogService)factory.getBean("requeLogService");
RequestLog entity = new RequestLog();
entity.setQueryId(21);
entity.setType("212");
entity.setcTime(new Timestamp(System.currentTimeMillis()));
service.save(entity);
}
bug:Field 'id' doesn't have a default value
原因是因为自己粗心,主键id并没有自增,没有勾选:AUTO_INCREMENT
代码:
public static void main(String[] args) {
ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:beans.xml");
RequestLogService service = (RequestLogService)factory.getBean("requeLogService");
RequestLog entity = new RequestLog();
entity.setQueryId(21);
entity.setType("212");
entity.setcTime(new Timestamp(System.currentTimeMillis()));
service.save(entity);
}
相关文章推荐
- UITableView - 重用机制
- mysql DECLARE CONTINUE HANDLER FOR NOT FOUND
- 13 UIGestureRecognizer and UIMenuController
- MySQL SQL优化案例:相关子查询(dependent subquery)优化
- Android 之UI自适应解决方案
- UITextView: 响应键盘的 return 事件
- android消息处理机制学习(一)-Handler,Message,MessageQueue,Looper简介
- [转] easyui 获取数据表格中选中行的数据 Get selected row data from...
- 自定义UIView动画效果
- 利用EasyUI combobox实现模糊搜索
- ueditor显示内容末尾有多余标记的解决
- 获取UILabel上最后一个字符串的位置。获取文字长度和高度,自动换行
- 实践自定义UI-ViewGroup
- Day3_UI布局--FXQ
- ~\sdk\build-tools\22.0.1\aapt.exe" finished with non-zero exit value 1
- iOS UI-集合视图(UICollectionView)
- 关于Android Studio中build.gradle文件的gradle路径存在问题
- 如何使用 require.js ,实现js文件的异步加载,避免网页失去响应,管理模块之间的依赖性,便于代码的编写和维护。
- UILable文字置顶的解决方案
- OS开发之AFNetworking-解决Servlet用request.getParameter("")无法获取到post参数的问题