hey guys,

I've been using a solution described here:

http://stackoverflow.com/questions/706673/forcing-nhibernate-to-cascade-delete-before-inserts

in order to force elements in a collection to be deleted before the
inserts (there's a unique constraint in place, and the new inserts
fail if they have the same unique constraint values as an element
that's just been deleted).

Basically, the code in the repository looks like this:

public void Save( Order orderObj ) {
     using (var trn = UnitOfWork.Current.BeginTransaction()) {
       session.SaveOrUpdate (orderObj);
       session.Flush();
       foreach( OrderLine line in orderObj.Lines )
       {
         session.SaveOrUpdate (line);
       }
       trn.Commit();
    }
}

This used to work fine (with the Lines collection set with a cascade
of "delete-only"), but has started to fail recently and I can't track
down what's changed (or whether it's an nHibernate change. Now I'm
getting an exception on session.Flush() saying that orderObj
references an unsaved or transient instance. Which it obviously does,
but I don't want nHibernate to care (and seemingly in the past it
didn't).

Does anyone have any suggestions how to work around this?

Thanks,

James

--~--~---------~--~----~------------~-------~--~----~
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