Koen Konst (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNmI4NTc0Yzc1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15561?atlOrigin=eyJpIjoiNmI4NT...
) HHH-15561 (
https://hibernate.atlassian.net/browse/HHH-15561?atlOrigin=eyJpIjoiNmI4NT...
) Function "IDENTITY" not found when inserting audited revision using Hibernate
Envers (
https://hibernate.atlassian.net/browse/HHH-15561?atlOrigin=eyJpIjoiNmI4NT...
)
Change By: Koen Konst (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
When inserting an audited revision I get the following error:
{noformat}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{noformat}
This error occurs with Hibernate Envers version 5.6.10 and H2 version 2.1.214. This blocks
us from upgrading Spring Boot from 2.6 to 2.7. It seems to be related to
[
https://hibernate.atlassian.net/browse/HHH-14985|https://hibernate.atlass...].
The table has successfully been created on startup of the integration test.
{noformat}Hibernate: create table audited_revision (id bigint generated by default as
identity, timestamp timestamp, primary key (id)){noformat}
My application.yml has the following configuration:
{noformat}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{noformat}
It seems that the new H2 dialect from version 2.X isn’t fully supported by Hibernate.
Our AuditedRevision entity:
{noformat}@Entity
@RevisionEntity
data class AuditedRevision
(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@RevisionNumber
var id: Long? = null,
@RevisionTimestamp
@Temporal(TemporalType.TIMESTAMP)
var timestamp: Date
) : Serializable {
companion object {
private const val serialVersionUID = -4310160L
}
}{noformat}
(
https://hibernate.atlassian.net/browse/HHH-15561#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15561#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:bddf6e1 )