java.sql.SQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist

SpringBoot 2.1.4

在使用Spring Data JPA时调用JpaRepository.save(Person)方法保存对象到mysql数据库中的时报错

java.sql.SQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist

解决方法

将@GeneratedValue改为@GeneratedValue(strategy=GenerationType.IDENTITY)解决问题

1 @Entity
2 public class Person {
3   @Id
4   @GeneratedValue
5   private Long id;
6   ...
7 }
1 @Entity
2 public class Person {
3   @Id
4   @GeneratedValue(strategy=GenerationType.IDENTITY)
5   private Long id;
6   ...
7 }

猜你喜欢

转载自www.cnblogs.com/kwpsz/p/10779078.html
今日推荐