Table 'DBNAME.hibernate_sequence' doesn't exist

en Peris picture en Peris · Apr 13, 2018 · Viewed 47.8k times · Source

I have a SpringBoot 2.0.1.RELEASE application using spring data / jpa

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

But when I do an update in the Amazon Aurora DB, I got this error:

2018-04-13 09:20 [pool-1-thread-1] ERROR o.h.id.enhanced.TableStructure.execute(148) - could not read a hi value com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'elbar.hibernate_sequence' doesn't exist at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

I have this in the entity I want to save

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

I would like to avoid also any drawback in the DB to fetch the ID .

Answer

Sadhil Spring picture Sadhil Spring · Apr 13, 2018

With the generation GenerationType.AUTO hibernate will look for the default hibernate_sequence table , so change generation to IDENTITY as below :

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;