插入已审核的修订时,出现以下错误:
Hibernate: insert into audited_revision (id, timestamp) values (default, ?)
2022-07-21 15:46:09.496 TRACE 67111 --- [ XNIO-1 task-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [TIMESTAMP] - [Thu Jul 21 15:46:09 CEST 2022]
Hibernate: call identity()
2022-07-21 15:46:09.504 WARN 67111 --- [ XNIO-1 task-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 90022, SQLState: 90022
2022-07-21 15:46:09.504 ERROR 67111 --- [ XNIO-1 task-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Function "IDENTITY" not found; SQL statement:
call identity() [90022-214]
2022-07-21 15:46:09.518 ERROR 67111 --- [ XNIO-1 task-1] o.z.problem.spring.common.AdviceTraits : Internal Server Error
org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [call identity()]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
根据Hibernate Jira上的这个问题,它应该在Hibernate core 5.6.5. https://hibernate.atlassian.net/browse/HHH-14985中修复。我目前使用的是Sping Boot 2.7.2提供的Hibernate core 5.6.9,但仍然遇到上述问题。根据以下日志记录,正确创建了该列:
Hibernate: create table audited_revision (id bigint generated by default as identity, timestamp timestamp, primary key (id))
我的相关应用程序。yaml配置:
spring:
jpa:
defer-datasource-initialization: true
database: H2
hibernate:
ddl-auto: create-drop
open-in-view: false
properties:
format_sql: true
org:
hibernate:
envers:
store_data_at_delete: true
hibernate:
temp:
use_jdbc_metadata_defaults: false
dialect: org.hibernate.dialect.H2Dialect
show-sql: true
这是Hibernate中的错误还是我做错了什么?
2条答案
按热度按时间qqrboqgw1#
在数据库连接中添加
MODE=LEGACY;
:实施例
application.yml
:application.properties:
yv5phkfx2#
此问题已在Hibernate核心5.6.13中修复
https://hibernate.atlassian.net/browse/HHH-15561