yeah i have cascade save/update for the parent objects on the
collections.  Cascade works fine on the first insert, but not on the
replicate.

Craig

On Apr 16, 10:57 am, Fabio Maulo <[email protected]> wrote:
> do you have explicit cascade action, on replicate, in the mapping  ?
>
> 2009/4/16 Fregas <[email protected]>
>
>
>
>
>
> > I have it partially working.  On root objects and man-to-one
> > relationships it seems to work fine.  However when it gets to parent/
> > child collections it messes up.
>
> > On the first save, it works fine.  Say I have a Customer with a
> > collection of orders,  NHibernate saves the Customer and the Orders
> > and each order record then has a foreign key called CustomerID back to
> > the customer.
>
> > On the replicate, it saves but the Orders no longer have a reference
> > back to their Customers in the table.  CustomerID ends up null.
>
> > Below is my code:
>
> > //first save - will do an insert/or update
> >            session.Save(workout);
>
> >            transaction.Commit();
>
> >            session.Close();
>
> > //replcate - should just do an insert
> >            var copySession = this._sessionBuilder.GetNewSession();
>
> >            copySession.Replicate(workout, ReplicationMode.Exception);
>
> >            copySession.Close();
>
> > On Apr 16, 8:15 am, Fregas <[email protected]> wrote:
> > > That will force an insert every time?  Is there an example somewhere?
>
> > > Thanks,
> > > Craig
>
> > > On Apr 15, 11:30 pm, Fabio Maulo <[email protected]> wrote:
>
> > > > session.Replicate
>
> > > > 2009/4/15 Fregas <[email protected]>
>
> > > > > I'm rephrasing this question because I'm not sure I'm expressing this
> > > > > correctly.
>
> > > > > I have a rather large object hierarchy with collections,
> > dictionaries,
> > > > > many-to-one relationships, etc.  When i get this hierarchy out of the
> > > > > db using session.get() and make modifications, when I send this back
> > > > > to the database to save, I'd like every object re-inserted (not
> > > > > updated) as new records.  This is for logging/auditing purposes.  The
> > > > > root object has a version# so I want all related objects to relate
> > > > > back to the newly inserted root and new records for all related
> > > > > objects.
>
> > > > > Thanks,
> > > > > Craig
>
> > > > --
> > > > Fabio Maulo
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to