From: NHibernate J. <nh...@gm...> - 2010-02-09 16:00:00
|
ClassCastException on flush for entities having collection when updating state in custom interceptor ---------------------------------------------------------------------------------------------------- Key: NH-2105 URL: http://nhjira.koah.net/browse/NH-2105 Project: NHibernate Issue Type: Patch Components: Core Affects Versions: 2.1.2.GA Reporter: Julien Letrouit Priority: Major Attachments: InterceptorCollectionBug.patch If you have an interceptor updating the state in the OnSave() of a custom interceptor, you will get a ClassCastException on flush. This is because the code that is converting regular collections to persisted collections is not called when the state of the entity is changed during the OnSave() operation. The problematic line is 240 in NHibernate/Event/Default/AbstractSaveEventListener.cs: if (persister.HasCollections) { HERE -> substitute = substitute || VisitCollectionsBeforeSave(entity, id, values, types, source); } If substitute is true, VisitCollectionsBeforeSave() is not called, making the collections to not be converted to their persisted equivalent. Inverting both arguments of the || comparison fixes the problem. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://nhjira.koah.net/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |