表'DBNAME.hibernate_sequence'不存在 [英] Table 'DBNAME.hibernate_sequence' doesn't exist

查看:57
本文介绍了表'DBNAME.hibernate_sequence'不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用spring data/jpa的SpringBoot 2.0.1.RELEASE应用程序

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>

但是当我在Amazon Aurora数据库中进行更新时,出现此错误:

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

2018-04-13 09:20 [pool-1-thread-1]错误o.h.id.enhanced.TableStructure.execute(148)-无法读取hi值 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:表"elbar.hibernate_sequence"在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处不存在

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;

我也希望避免在数据库中获取ID的任何缺点.

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

推荐答案

对于生成的GenerationType.AUTO,hibernate将查找默认的hibernate_sequence表,因此将生成的内容更改为IDENTITY,如下所示:

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;

这篇关于表'DBNAME.hibernate_sequence'不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆