These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Parent - Child problems
PostPosted: Wed Nov 09, 2005 3:42 pm 
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.


Top
  
 
 Post subject: Found problem
PostPosted: Wed Nov 09, 2005 4:42 pm 
Please ignore or delete this post. The problem occured in the code where I assigned the child to the parent.

Sorry for the inconvenience.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.