【问题标题】:Envers not Saving Audits-NhibernateEnvers 不保存审计-Nhibernate
【发布时间】:2013-01-14 17:01:22
【问题描述】:

我有以下环境配置:

        hibernateCfg.SetEnversProperty(ConfigurationKey.DefaultSchema, "audit");
        hibernateCfg.SetEnversProperty(ConfigurationKey.RevisionFieldName, "Rev");
        hibernateCfg.SetEnversProperty(ConfigurationKey.RevisionTypeFieldName, "RevType");
        hibernateCfg.SetEnversProperty(ConfigurationKey.AuditTableSuffix, "_Audit");

        var cfg = new FluentConfiguration();
        cfg.SetRevisionEntity<RevisionInfo>(x => x.Id, x => x.RevisionTimestamp, new RevisionListener());

        cfg.Audit<User>().Exclude(x=>x.Account).Exclude(x=>x.Agentie).Exclude(x=>x.Location).Exclude(x=>x.Produse).Exclude(x=>x.Roles);
        //cfg.Audit<Account>().ExcludeRelationData(x => x.Users);
        //cfg.Audit<Document>();

        hibernateCfg.IntegrateWithEnvers(new EnhancedAuditEventListener(), cfg);

没有创建审计表,也没有保存数据。我曾尝试自己创建表audit.User_Audit,但没有任何变化。我有 nhibernate envers 1.30 和 nhibernate 3.3.1。

我需要其他配置来完成这项工作吗?

【问题讨论】:

  • 我看不出有什么问题。您确定“hibernateCfg”是您构建 ISessionFactory 的配置吗?实体用户的属性比您排除的属性多?
  • 是的 hibernateCfg 没问题。问题出在用户实体上(如下所述)。谢谢

标签: nhibernate nhibernate-envers


【解决方案1】:

我解决了。问题是我有一些来自用户的派生类(如 BrokerUser :用户),我将其与鉴别器一起使用。我添加后:

cfg.Audit<BrokerUser>()

问题解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 2011-09-13
    相关资源
    最近更新 更多