vfl*_*gel 9 postgresql hibernate-envers spring-boot
我正在迁移到 SpringBoot 3.0.1 并将“hibernate-envers”版本更新为“6.1.6.Final”。我的数据库是 PostgreSQL 13.6。Hibernate 配置为创建数据库模式:
spring.jpa.hibernate.ddl-auto:create
启动应用程序后,我收到以下错误:
pim 2022-12-27 12:00:13,715 WARN C#c7b942ec-33b4-4749-b113-22cbb2946a8d [http-nio-9637-exec-1] SqlExceptionHelper/133 - SQL Error: 0, SQLState: 42P01
pim 2022-12-27 12:00:13,715 ERROR C#c7b942ec-33b4-4749-b113-22cbb2946a8d [http-nio-9637-exec-1] SqlExceptionHelper/138 - ERROR: relation "revinfo_seq" does not exist
Position: 16
Run Code Online (Sandbox Code Playgroud)
revinfo 表如下所示:
create table revinfo
(
revision bigint not null
primary key,
client_id varchar(255),
correlation_id varchar(255),
origin varchar(255),
request_id varchar(255),
revision_timestamp bigint not null,
timestamp_utc timestamp with time zone,
user_name varchar(255)
);
Run Code Online (Sandbox Code Playgroud)
序列“revinfo_seq”不存在,但在带有 envers 的旧数据库结构中
5.6.8.Final
Run Code Online (Sandbox Code Playgroud)
而 SpringBoot 2.6.6 它也不存在,没有任何问题。我缺少什么?
我尝试切换参数
org.hibernate.envers.use_revision_entity_with_native_id
Run Code Online (Sandbox Code Playgroud)
但这没有帮助。
vva*_*ruz 17
你可以用这个属性来解决它:
spring.jpa.properties.hibernate.id.db_structure_naming_strategy: legacy
使用 Spring Boot 3.0.1 进行测试
原因:
Hibernate 6 改变了序列命名策略,因此它正在搜索以“_seq”结尾的序列。您可以在这里阅读非常详细的解释: https: //thorben-janssen.com/sequence-naming-strategies-in-hibernate-6/
| 归档时间: |
|
| 查看次数: |
4625 次 |
| 最近记录: |