Envers not Saving Audits-Nhibernate

570 views Asked by At

I have the following envers configuration:

        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);

No Audit Table is created and no data is saved. I have tried creating the table audit.User_Audit myself, but nothing changes. I have nhibernate envers 1.30 and nhibernate 3.3.1.

Do I need another configuration to make this work?

1

There are 1 answers

0
Catalin On BEST ANSWER

I solved it. The problem was that I had some derived classes from User (Like BrokerUser : User) which I used with discriminators. After I added:

cfg.Audit<BrokerUser>()

the problem was solved.