Table #39;DBNAME.hibernate_sequence#39; doesn#39;t exist(表 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:sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)中不存在表elbar.hibernate_sequence"
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' 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:表 'DBNAME.hibernate_sequence' 不存在


基础教程推荐
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01