加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – 目前不支持公式映射 – Hibernate ORM Envers

发布时间:2020-12-15 01:41:43 所属栏目:大数据 来源:网络整理
导读:我使用Hibernate Envers: @Entity @Table(name = "user")@Auditedclass User(){ private String id; @Formula("(SELECT name FROM other c where c.id = id)") private Integer name;} 它抛出: [org/springframework/boot/autoconfigure/orm/jpa/Hibernate

我使用Hibernate Envers:

@Entity 
@Table(name = "user")
@Audited
class User()
{
    private String id;
    @Formula("(SELECT name FROM other c where c.id = id)")
    private Integer name;
}

它抛出:

[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is
org.hibernate.envers.configuration.internal.metadata.FormulaNotSupportedException:
Formula mappings (aside from @DiscriminatorValue) are currently not
supported

如何使用@Formula和Hibernate Envers计算实体属性?

仅供参考当我删除Hibernate Envers时,它可以正常工作.

最佳答案
问题是你要求Envers审核一个@Formula注释列,目前不支持该列.我打开JIRA HHH-11785只是为了进一步研究这个问题.

但是,您应该能够使用@NotAudited注释公式字段,并且Envers应该与该配置完全集成.真正的问题是,当它发现要跟踪基于公式的字段的历史时,它会失败.

举个例子:

@Entity
@Audited
class User {
  @Formula("SELECT name FROM Other ...")
  @NotAudited
  private String name;
  // other attributes
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读