问题7:当使用jpa操作数据库的时候,插入数据到数据库使用主键自增策略时候报错:Springboot-jpa Table 'sell.hibernate_sequence' doesn't exist

问题7:当使用jpa操作数据库的时候,插入数据到数据库使用主键自增策略时候报错:Springboot-jpa Table 'sell.hibernate_sequence' doesn't exist

解决方式:需要在实体中加入注释:

最开始我是在主键上边加入:

@Id
@GeneratedValue
private Integer categoryId;

然后就报错,需要进行修改:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer categoryId;

测试代码如下:

查看数据库:

猜你喜欢

转载自blog.csdn.net/Handsome2013/article/details/84133361