Table 'DBNAME.hibernate_sequence' doesn't exist

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 .


Solution 1:

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;

Solution 2:

Add the following config in your application.yml:

spring: jpa: hibernate: use-new-id-generator-mappings: false

Or this if you use application.properties

spring.jpa.hibernate.use-new-id-generator-mappings= false