天天看点

mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'sell.hibernate_sequence' doesn't exit

SpringBoot整合Jpa时调用JpaRepository的save方法保存对象时报错。

@Entity
public class ProductCategory {
    /*  类目ID*/
    @Id //主键
    @GeneratedValue //自增
    private Integer categoryId;
    /* 类目名*/
    private String categoryName;
    /*类目编号*/
    private Integer categoryType;      
将上述标红的注解改为下述注解即可。      
IDENTITY :主键是由数据库生成的,例如数据库中设置了主键自增。      
@Entity
public class ProductCategory {
    /*  类目ID*/
    @Id //主键
    @GeneratedValue(strategy = GenerationType.IDENTITY)  //自增
    private Integer categoryId;
    /* 类目名*/
    private String categoryName;
    /*类目编号*/
    private Integer categoryType;      

继续阅读