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