The INSERT is fired immediately and not at Flush/commit because you are using identity.
On Tue, May 3, 2011 at 1:52 AM, David Slayton <[email protected]>wrote: > Yes, thank you, I will look into filing a JIRA with a test. Do you > mean by, "you have always an INSERT," that just creating the object > without calling SaveOrUpdate on the top level object in graph (for > cascade behavior) can cause persistence? Ah I see, I was not clear; I > meant that in order for us to avoid generating the exception we are > calling SaveOrUpdate on the object to persist and then orphaning the > object to get it deleted. > > On Apr 29, 5:30 am, Fabio Maulo <[email protected]> wrote: > > btw David please file a JIRA with a test attached. > > We have modified the behavior to prevent an exception for transient obj > and > > perhaps that test is not complete or, more probably, was not using > identity > > as generator. > > > > > > > > > > > > On Fri, Apr 29, 2011 at 9:20 AM, Fabio Maulo <[email protected]> > wrote: > > > You don't have to persist, you have already persisted those objects > (you > > > have always an INSERT). > > > > > On Thu, Apr 28, 2011 at 11:50 PM, David Slayton < > [email protected]>wrote: > > > > >> I am working on an application that uses NHibernate 3.1.0 and builds a > > >> large object graph of results (new unsaved transient objects), but, > > >> depending on the status of the process, needs to exclude some of the > > >> results from persistence. The method the application currently uses > > >> to prevent persistence of new unsaved objects is to orphan them and > > >> rely on garbage collection to clean them up. This works fine when > > >> cascading all, but does not work when cascading all-delete-orphan. > > > > >> In the GetOrphans method of AbstractPersistentCollection I noticed > > >> that the gathering of the currentIds filters out transient objects: > > > > >> if (current != null && ForeignKeys.IsNotTransient(entityName, > > >> current, null, session)) > > > > >> but there is no corresponding filter when iterating over the old list > > >> before the call to GetEntityIdentifierIfNotUnsaved and > > >> GetEntityIdentifierIfNotUnsaved method will throw an exception if the > > >> object does not have an identifier and is transient. We derive our > > >> identifiers from identity column in the database (I understand that > > >> this is not recommended practice, but the database for this > > >> application was architected before adopting NHibernate) so we have to > > >> persist to the database before orphaning the object in order for > > >> cascade all-delete-orphan. > > > > >> Is it necessary for GetOrphans to include evaluation of transient > > >> objects for the old list? I'm wondering why currentIds only includes > > >> non-transient objects, but the old list does not include the same > > >> restriction. > > > > >> Regards, > > >> David Slayton > > > > > -- > > > Fabio Maulo > > > > -- > > Fabio Maulo- Hide quoted text - > > > > - Show quoted text - -- Fabio Maulo
