表格'DBNAME.hibernate_sequence'不存在。

36 浏览
0 Comments

表格'DBNAME.hibernate_sequence'不存在。

我有一个使用Spring Data / JPA的SpringBoot 2.0.1.RELEASE应用程序

    org.springframework.boot
    spring-boot-starter-data-jpa

但是,当我在Amazon Aurora DB中进行更新时,我得到了以下错误:

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)

我在我想要保存的实体中有这个

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

我也想避免在数据库中获取ID时出现任何问题。

admin 更改状态以发布 2023年5月22日
0
0 Comments

在你的application.yml中添加以下配置:

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

如果你使用application.properties时则添加以下配置:

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

0
0 Comments

使用 GenerationType.AUTO,Hibernate 将寻找默认的 hibernate_sequence 表,因此将生成方式更改为以下的 IDENTITY

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

0