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 .
By default, Hibernate generates key from hibernate_sequence table, we can disable it by setting this hibernate. use-new-id-generator-mappings to false.
If you use strategy="AUTO" , Hibernate will generate a table called hibernate_sequence to provide the next number for the ID sequence. You may have forgotten to add the AutoIncrement feature to your table's PK.
hibernate_sequence' doesn't exist error occurs when the hibernate_sequence table does not exist in the database and auto id generation in hibernate is enabled. Hibernate generates and stores the current id for auto-increment column values in the hibernate sequence table. The error java. sql.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With