SpringBoot JPA 报错 ids for this class must be manually assigned

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wokenshin/article/details/81225292

在进行数据插入的时候报错
关键信息如下
这里写图片描述

出现这样的错误,目前遇到两种情况

1、实体类中的id是自增类型 而没有添加 自增对应的注解,需要添加 @GeneratedValue
2、就是插入的时候插入的id == null 。。。。
如果你的id字段不是自增类型的就不用添加上面的@GeneratedValue注解了


 /** 类目id. */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)//起初是没有括号中的内容的 后来测试保存方法的时候报错 就新增了括号中的内容 详细:https://blog.csdn.net/heatdeath/article/details/79841171
    private Integer categoryId;
 @Id
 private String orderId;

猜你喜欢

转载自blog.csdn.net/wokenshin/article/details/81225292
今日推荐