-->
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.  [ 1 post ] 
Author Message
 Post subject: Error - collection was modified under parent/child mapping.
PostPosted: Tue Jan 31, 2012 1:04 am 
Newbie

Joined: Thu Dec 30, 2004 2:15 am
Posts: 1
Dears,

we got a big trouble on persisting domain object under parent/child relationships. the error message was:NHibernate: Collection was modified; enumeration operation may not execute.

pls help to review the stuffs, thanks.

(1) mapping file:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name=Orgnization, BizModel" table="OGNZ" proxy="IOrgnization, BizModel">
        <id name="EntityId" type="string" unsaved-value="null">
            <column name="OrgId" sql-type="integer" not-null="true" unique="true"/>
            <generator class="native"/>
        </id>
        ...
        <many-to-one name="ParentUnit" class="Orgnization, BizModel" unique="true">
            <column name="ParentOrgId" sql-type="int"/>
        </many-to-one>
        <bag name="SubUnits" cascade="save-update" inverse="true" lazy="true" order-by="OrgCode">
            <key column="ParentOrgId"/>
            <one-to-many class="Orgnization, BizModel"/>
        </bag>
    </class>
</hibernate-mapping>


(2) code

Code:
IOrgnization oParentDept = _orgnizationRepository.GetOrgnizationByCode("GM");
IEmployee oBoss = _employeeRepository.GetByEmployeeNo("E000001");

IOrgnization oDept = _bizEntityFactory.CreateEntityInstance<IOrgnization>() as IOrgnization;
oDept.Code = "GM01";
oDept.Name = "GM Sub 01";
oDept.ParentUnit = oParentDept;
oDept.Boss = oBoss;

_orgnizationRepository.Save(oDept);


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

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.