Thank you for an answer Fabio. I've just resolved my problem. In the mean time I realized, that the entity load and entity session has been done in two seperate sessions. After entities load the session has been cleared and disposed. After that some operations on the entities collection has been performed and then modified objects were saved.
I've used a update method which causes the mentioned problem. The solution to that in my case was replacing an update method with a merge method. The merge method works as I expected. Maybe this info will help someone. Regards, Miloszes On Feb 18, 5:10 am, Fabio Maulo <[email protected]> wrote: > http://nhforge.org/doc/nh/en/index.html#manipulatingdata-graphs > "If a transient child is dereferenced by a persistent parent, nothing > special happens (the application should explicitly delete the child if > necessary) unless cascade="all-delete-orphan", in which case the "orphaned" > child is deleted." > > In case of bidirectional-one-to-many with inverse=true you can also use > <key column="id_parent" on-delete="cascade"/> > > 2010/2/17 MiloszeS <[email protected]> > > > > > > > Hi all, > > > I have two classes: > > > Parent(1) and (*)Child. > > > I've spotted a weird situation. When I fetch a Parent object (with a > > Child collection) using UniqueResult<Parent> and after that Update a > > Parent (I didn't made any modifications on Parent nor any Child > > objects) nhibernate inserts a new copy of each Child object into a > > db. > > > Example: > > > We've got a one Parent entity P1 and four Child entities: C1, C2, C3, > > C4 in the db. After a mentioned process (fetch + update) we'll got one > > Parent P1 and eight Child entities - four original and four copies. > > > Could anyone explain me what happens? > > > More Info: > > > NH: 2.0.1.4 > > > Parent.xml: > > > <hibernate-mapping namespace="namespace" assembly="assembly" > > xmlns="urn:nhibernate-mapping-2.2"> > > <class name="namespace.Parent" table="parent" schema="schema"> > > <id name="ID" type="Int64"> > > <column name="id" not-null="true" /> > > <generator class="sequence"> > > <param name="sequence">sequence_name</param> > > </generator> > > </id> > > > ... > > > <bag name="Children" table="children" schema="schema" lazy="false" > > inverse="true" cascade="all"> > > <key column="id_parent" /> > > <one-to-many class="Child" /> > > </bag> > > > ... > > > </class> > > </hibernate-mapping> > > > Regards, > > MiloszeS > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<nhusers%[email protected] > > > > > . > > For more options, visit this group at > >http://groups.google.com/group/nhusers?hl=en. > > -- > Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
