First of all I'd like to say that I've had a great experience with NHibernate. However, this last problem has me stumped.
It's a classic Parent-Child relationship for Report - ReportDetails
My parent class: Report has xml like the following.
<bag
name="ReportDetails"
cascade="all-delete-orphan"
inverse="true"
lazy="true" >
<key
column="ReportId" />
<one-to-many
class="eg.ReportDetail, eg" />
</bag>
My child class: ReportDetails has xml like the following.
<many-to-one
name="Report"
column="ReportId"
not-null="true"
class="eg.Report, eg"
cascade="none"
/>
The report class has the following as a field mapped to a public property.
private ArrayList reportDetails;
//This is an ArrayList.
and the ReportDetail class as
Code:
private Report report;
I first create and save the report using
Code:
session.Save(report);
and then I add many ReportDetail instances to the report.ReportDetails IList. When I'm done I call
Code:
session.Flush();
The error I get is
"Enumeration already finished."
and the StackTrace =
" at System.Collections.ArrayListEnumeratorSimple.get_Current()\r\n at NHibernate.Engine.Cascades.CascadeCollection(CascadingAction action, CascadeStyle style, PersistentCollectionType collectionType, IType elemType, Object child, CascadePoint cascadeVia, ISessionImplementor session, Object anything)\r\n at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)\r\n at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, IClassPersister persister, Object parent, CascadingAction action, CascadePoint cascadeTo, Object anything)\r\n at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, IClassPersister persister, Object parent, CascadingAction action, CascadePoint cascadeTo)\r\n at NHibernate.Impl.SessionImpl.PreFlushEntities()\r\n at NHibernate.Impl.SessionImpl.FlushEverything()\r\n at NHibernate.Impl.SessionImpl.Flush()\r\n ... 93"
Any help will be GREATLY appreciated.
Thanks.