Question

We are using NHibernate and Envers. Everything works fine, but envers is not inserting audits for deleting orphans.

Inverse().Cascade.AllDeleteOrphan()

Where can I find a good envers documentation for nhibernate? Is it possible at all so that evers is doing delete entries in history tables for deleting an orphan?

...
entity.SomeCollection.Clear(); //Orphans will be deleted because cascade is AllDeleteOrphan.
tx.commit();

Best regards!

No correct solution

OTHER TIPS

Yep, found the answer myself. Envers is doing inserts for orphan deletes:

ISession session = sessionFactory.OpenSession();
ITransaction tx = session.BeginTransaction();

MyItem item = session.Get<MyItem>(44); //Item enthält ein Tag.

item.Tags.Clear();

tx.Commit(); 

session.Close();

But only if the relation end is not declared inverse.

    HasManyToMany(x => x.Items)
        .Table("MyItem_MyTag")
        .ParentKeyColumn("MyTagID")
        .ChildKeyColumn("MyItemID")
        .Cascade.All()
        .Inverse().LazyLoad();

If you want an entry non the less, then add:

nhibernate.envers.revision_on_collection_change

http://envers.bitbucket.org/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top