JPA报错(could not execute statement)
程序员文章站
2024-03-13 17:48:27
...
错误提示
could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
发生错误的代码
@RequestMapping("/useradd")
@ResponseBody
@Transactional(value = "transactionManager")
public String AddUser()
{
for (int i=0;i<100;i++)
{
User user=new User();
user.setUsername("测试"+i);
user.setUserpwd("123456");
User save = this.userRepository.save(user);
}
return "成功!" ;
}
在保存用户的时候发生的错误,经过查证,原来是因为实体类User对应的数据表Id不是自增字段,所以去表里面修改一下
解决方法
人生到底有多少天?其实只有三天:昨天、今天、明天。经营好这三天,就经营好了一生。而昨天已过去,明天还未到,我们现在所能掌握的就是今天。
共同学习,共同进步,技术交流群:
推荐阅读
-
JPA报错(could not execute statement)
-
linux安装数据时报错Could not execute auto check for display colors using command /usr/bin/xdpyinfo.
-
linux安装数据时报错Could not execute auto check for display colors using command /usr/bin/xdpyinfo.
-
mvn build 报错 [ERROR] Failed to execute goal on project demo: Could not resolve dependencies
-
Jpa项目报错:org.hibernate.lazyinitializationexception could not initialize proxy - no session