【问题标题】:How to add field which is not audited by Envers to audit table如何将未经 Envers 审计的字段添加到审计表
【发布时间】:2020-08-02 18:37:04
【问题描述】:

我正在寻找有关如何将字段包含到未标记为@Audited 的审计表的解决方案。

我有这样一个数据库结构:

create table user (
    id CHAR(36) not null,
    first_name varchar(200) not null,
    last_name varchar(200) not null,
    phone_number varchar(15),
    primary key (id)
);

@Audited 注解放置在 User.class 中的 first_name 和 last_name 字段中,结果创建了下面的审计表:

create table user_aud (
    id CHAR(36) not null,
    rev integer not null,
    revtype tinyint,
    first_name varchar(200),
    last_name varchar(200),
    primary key (id,rev)
) engine=InnoDB;

我还想在我的 user_aud 表列中添加 phone_number 但 phone_number 更改不应创建新修订。我不想关注 phone_number 的变化,但仍将其作为审核记录的一部分。

如果可能的话,我将不胜感激如何做到这一点。我使用的是 5.4.4.Final Hibernate 版本。

【问题讨论】:

    标签: spring hibernate jpa hibernate-envers


    【解决方案1】:

    查看此主题,如果它涵盖您的情况,请告诉我。对我来说,它似乎对你有用。

    not to create revision for particular column change

    【讨论】:

    • 似乎没有比编写自定义审计监听器更简单的解决方案了。感谢您的回答。
    • 是的,我相信没有别的办法
    猜你喜欢
    • 2018-12-28
    • 2018-09-19
    • 2018-08-09
    • 2015-12-14
    • 2023-03-24
    • 2021-03-14
    • 1970-01-01
    • 2012-08-10
    • 1970-01-01
    相关资源
    最近更新 更多