您的位置:首页 > 产品设计 > UI/UE

[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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: