NHibernate Intuition Does Not Require Set-List / List Changes

I have an application that uses NHibrenate, and I use an interceptor based solution for logging / auditing.

Basically, I have a class that inherits from EmptyInterceptor and overrides OnFlushDirty, OnSave, and OnDelete.

Everything works fine - except that when I add or remove from a set or list that is displayed using many-to-many, without changing any other properties, none of the interceptor methods are called.

How can I connect to NHibrenate and detect these changes?

The class is as follows:

public class SomeClass
{
  ... properties ..
  private Iesi.Collections.ISet _setOfOthers = new Iesi.Collections.HashedSet();
  public virtual Iesi.Collections.ISet SetOfOthers
  {
    get { return _setOfOthers; }
    set { _setOfOthers = value; }       
  }
  ... some more properties ...

}

With this hbm mapping:

<class name="MyAssembly.SomeClass, MyAssembly" table="[SomeClass]">
   ... properties ..
   <set name="SetOfOthers" table="SomeClass_SetOfOthers" cascade="none">
      <key column="Owner" />
      <many-to-many column="Item" class="MyAssembly.OtherClass, MyAssembly" />
   </set>
   .. some more properties ...
</class>

NHibrenate 2.0.1 ( ), NHibrenate - , .

.

+3
2

?

?

config.SetInterceptor(new YouInterceptor());

, , ?

if (config.Interceptor != null)
{
    session = factory.OpenSession(config.Interceptor);
}
else
{
    session = factory.OpenSession();
}
0

Source: https://habr.com/ru/post/1749192/


All Articles