Hibernate Envers 审计 Table 列从 jsonb 更改为 uuid
Hibernate Envers audit Table Column Changes from jsonb to uuid
我在实体中有一个 jsonb 列,其注释如示例代码所示。没有 @Audited 注释一切正常。添加 Audited 注释会创建 org_master_aud table,其列 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
在 main 和 audit table 中的 custom_fields 列的快照下方找到其中 audit table 列是 uuid 而 main table 是 jsonb。两者都是自动生成的。
将休眠版本从 5.4.12.Final 更新到 5.4.14.Final.
后,此问题已解决
这是版本 > 5.4.10 中引入的错误,已在 5.4.14 中修复。这是 link 到 jira 的问题。
我在实体中有一个 jsonb 列,其注释如示例代码所示。没有 @Audited 注释一切正常。添加 Audited 注释会创建 org_master_aud table,其列 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
在 main 和 audit table 中的 custom_fields 列的快照下方找到其中 audit table 列是 uuid 而 main table 是 jsonb。两者都是自动生成的。
将休眠版本从 5.4.12.Final 更新到 5.4.14.Final.
后,此问题已解决这是版本 > 5.4.10 中引入的错误,已在 5.4.14 中修复。这是 link 到 jira 的问题。