【问题标题】:Hibernate Envers audit Table Column Changes from jsonb to uuidHibernate Envers 审计表列从 jsonb 更改为 uuid
【发布时间】:2020-05-05 15:00:23
【问题描述】:

我在一个实体中有一个 jsonb 列,如示例代码所示。没有 @Audited 注释一切正常。添加 Audited 注释会创建 org_master_aud 表,其列 custom_fields 类型为 uuid 而不是 jsonb,并且插入失败

@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
@Audited
public class OrgMaster {
    @Type(type = "jsonb")
    @Column(columnDefinition = "jsonb",name="custom_fields",nullable=false)
    private JsonNode customFields;
}
org.springframework.orm.jpa.JpaSystemException: Unable to perform beforeTransactionCompletion callback: org.hibernate.exception.DataException: could not execute statement; nested exception is org.hibernate.HibernateException: Unable to perform beforeTransactionCompletion callback: org.hibernate.exception.DataException: could not execute statement
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:353)
.
.
.
.
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1352)
    ... 94 more
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type uuid: "{}"
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159)
    at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:125)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
    ... 105 more

在主表和审计表中 custom_fields 列的快照下方找到,其中审计表列是 uuid,而主表是 jsonb。两者都是自动生成的。

【问题讨论】:

    标签: spring hibernate hibernate-envers


    【解决方案1】:

    将休眠版本从 5.4.12.Final 更新到 5.4.14.Final 后,此问题已得到解决。

    这是版本 > 5.4.10 中引入的错误,并已在 5.4.14 中修复。这是 jira 问题的链接。

    https://hibernate.atlassian.net/browse/HHH-13886

    【讨论】:

    • 我正在使用 Spring Boot 2.3.1.RELEASE,其中包含休眠环境版本 5.4.17.FINAL。不幸的是,我面临着完全相同的问题。有什么想法吗?
    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 2015-02-22
    • 2018-09-19
    • 2015-08-20
    • 1970-01-01
    • 2015-12-14
    • 2016-03-19
    • 2022-12-14
    相关资源
    最近更新 更多