spring - Hibernate Envers 审计表列从 jsonb 更改为 uuid
问题描述
我在一个实体中有一个 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。两者都是自动生成的。
解决方案
将休眠版本从 5.4.12.Final 更新到 5.4.14.Final 后,此问题已得到解决。
这是版本 > 5.4.10 中引入的错误,并在 5.4.14 中修复。这是jira问题的链接。
推荐阅读
- css - CSS 变换导致 Safari 上的动画出现问题
- c++ - 用文本c ++复制数字
- python - Pytorch/torchvision - 如何增加可检测物体的限制
- flutter - 如果没有数据抖动如何显示警报消息
- python - Keras“循环”层中的函数
- reactjs - 这是我在使用图像并将 URL 保存到数据库后得到的错误反应
- arrays - 包含函数的数组总和 - C
- sql - 带有 NULL NOT IN 子句的 TSQL,它会失败还是不会?
- python - 在 Python 中执行不同函数组合的最佳方法
- c# - 为什么 DisplayMemberPath 不起作用 在列表视图中使用?