Bizarre NHibernate exception: "An uninitialized proxy is passed to save ()." triggered by factory event configuration

The mere presence of a custom subclass of DefaultSaveEventListener that does not contain hidden or extended behavior is enough to cause this strange exception for me when flushing or committing a transaction using the following Xml configuration:

 <event type="save-update"> <listener class="MyNamespace.MyCustomSaveEventListener, MyAssembly" /> </event> 

If I comment on the above, it works great. But, as I said, this happens despite the fact that there is no overridden or extended behavior of the event listener. I know that these <event> elements are not additive for the default NHibernate configuration, so everything that is configured in this element replaces everything else, hence the usual practice of obtaining default implementations.

An exception occurs in the NHibernate.Event.Default.DefaultSaveOrUpdateEventListener class as part of the ReassociateIfUninitializedProxy method. This happens even when registering only this registrar and all other interceptions / extensions from the factory configuration.

Anyone have any ideas on this? I need to implement some advanced behavior using this listener interface. Catching an exception and throwing it does no harm, but what should be the return value?

0
events listener nhibernate
source share
1 answer

Oops got from DefaultSaveEventListener instead of DefaultSaveOrUpdateEventListener ... changing the superclass made the problem go away - it should open my eyes.

+1
source share

All Articles