nhibernatenhibernate-envers

Nhibernate envers modified columns doesn't correctly track removals from collection


I've got a model that looks like:

class Case
{
    public virtual ISet<CaseToCaseTag> CaseTags { get; set; }
    public virtual DateTime LastModified { get; set; }
}

class CaseToCaseTag
{
    public virtual Case Left { get; set; }
}

When auditing this relationship with envers, I'm running into problems with the modified property tracking when removing values from the set.

If the only thing I change in the case-entity when removing a value from the set is the "set-removal" then envers correctly tracks that the CaseTags property is modified in the revision. However, if I also change any other property, for instance the LastModified property, I don't get the CaseTags_MOD flag correctly set.

I've tracked this down (I think) to the AuditProcess.AddWorkUnit method. When I only remove from the set only one WorkUnit gets added (a CollectionChangeWorkUnit), but when I also change another property, another WorkUnit (a ModWorkUnit) also gets added.

What seems to happen then is that the CollectionChangeWorkUnit is discarded in favor of the ModWorkUnit, which in turn doesn't pick up the changes to the collection.

Is what I'm trying to do not supported, or is there a way around it?


Solution

  • Sounds like a bug. Please create a pull request with minimal mapping to reproduce the issue.