Bizarre NHibernate exception: 'Uninitialized proxy passed to save().' caused by factory event configuration
There mere presence of a custom DefaultSaveEventListener
subclass containing no overidden or extended behaviour is enough to trigger this bizarre exception for me when flushing or committing a transaction, using the following configuration Xml:
<event type="save-update">
<listener class="MyNamespace.MyCustomSaveEventListener, MyAssembly" />
</event>
If I comment out the above, it works fine. But like I say, this occurrs even though there is no overridden or extended event listener behaviour defined. I am aware that these <event>
elements don't appear to be additive to the default NHibernate configuration, so whatever is configured in this element replaces everything else, hence the common practice of deriving from default implementations.
The exception occurs in the class NHibernate.Event.Default.DefaultSaveOrUpdateEventListener
within the ReassociateIfUninitializedProxy
method. It occurs even with only this listener registe开发者_运维百科red and all other interception/extensions removed from the factory configuration.
Anybody any ideas on this? I need to implement some extended behaviour using this listener interface. Catching the exception and throwing it away doesn't appear to do any damage but what should the return value be?
Whoops was deriving from DefaultSaveEventListener
instead of DefaultSaveOrUpdateEventListener
... changing the superclass made the problem go away - should open my eyes.
精彩评论