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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM