Hibernate-envers + Liquebase(ddl-auto=none)。可以用吗?

问题描述 投票:0回答:1

我的问题涉及 hibernate-envers lib。 我有 springboot 项目,带有 liquibase + spring.jpa.hibernate.ddl-auto=none。因此,如果添加Hibernate-envers,则需要创建schema some_table_aud、revinfo等。我意识到官方文档https://docs.jboss.org/envers/docs/index.html,但没有发现它足够理解嵌入到我的项目中。 问题:Liquibase 已执行具有以下审核模式的 sql 文件,但在创建/更新/删除实体(resourcesupport_program)后尚未填充审核数据。

有人有成功使用 Liquebase(ddl-auto=none) + Hibernate-envers 的经验吗? 提前谢谢你)

create sequence if not exists hibernate_sequence;

CREATE TABLE revinfo
(
    rev integer ,
    revtstmp  bigint NOT NULL,
    user_id bigint ,
    CONSTRAINT pk_revinfo PRIMARY KEY (rev)
);

ALTER TABLE revinfo ADD CONSTRAINT
    fk_revinfo_user_id_users_id
    FOREIGN KEY ( user_id ) REFERENCES users(id);

CREATE INDEX revinfo_user_id_idx ON revinfo USING btree (user_id);

CREATE TABLE cross_revinfo_users
(
    user_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    revinfo_id integer NOT NULL,
    CONSTRAINT pk_cross_revinfo_users PRIMARY KEY (user_id, revinfo_id),
    CONSTRAINT fk_cross_revinfo_users_user_id FOREIGN KEY(user_id) REFERENCES users(id),
    CONSTRAINT fk_cross_revinfo_users_revinfo_id FOREIGN KEY(revinfo_id) REFERENCES revinfo(rev)
);

CREATE TABLE resources_aud
(
    id BIGINT NOT NULL ,
    rev INTEGER NOT NULL ,
    REVTYPE SMALLINT ,
    REVEND INTEGER ,
    created_at timestamp NULL ,
    eosl_date timestamp NULL ,
    support_program_id BIGINT NULL ,
    CONSTRAINT pk_resources_aud PRIMARY KEY ( id, rev )
);

ALTER TABLE resources_aud ADD CONSTRAINT
    fk_resources_aud_rev_revinfo_rev
    FOREIGN KEY ( rev ) REFERENCES revinfo(rev);

ALTER TABLE resources_aud ADD CONSTRAINT
    fk_resources_aud_revend_revinfo_rev
    FOREIGN KEY ( REVEND ) REFERENCES revinfo(rev);

CREATE INDEX resources_aud_rev_idx ON resources_aud USING btree (rev);
CREATE INDEX resources_aud_revend_idx ON resources_aud USING btree (REVEND);

CREATE TABLE support_programs_aud
(
    id BIGINT NOT NULL ,
    rev INTEGER NOT NULL ,
    REVTYPE SMALLINT ,
    REVEND INTEGER ,
    created_at timestamp NULL ,
    title VARCHAR(255) NULL ,
    CONSTRAINT pk_support_programs_aud PRIMARY KEY ( id, rev )
);

ALTER TABLE support_programs_aud ADD CONSTRAINT
    fk_support_programs_aud_rev_revinfo_rev
    FOREIGN KEY ( rev ) REFERENCES revinfo(rev);

ALTER TABLE support_programs_aud ADD CONSTRAINT
    fk_support_programs_aud_revend_revinfo_rev
    FOREIGN KEY ( REVEND ) REFERENCES revinfo(rev);

CREATE INDEX support_programs_aud_rev_idx ON support_programs_aud USING btree (rev);
CREATE INDEX support_programs_aud_revend_idx ON support_programs_aud USING btree (REVEND);
hibernate hibernate-envers
1个回答
0
投票

您的实体怎么样?你需要这个注释 @审计 @AuditTable()

© www.soinside.com 2019 - 2024. All rights reserved.