What you are seeing is only the first level of your object graph.
If you want change the NH behavior try to think in something more complex
not only using an object graph with collection etc. but even using different
hierarchy-persistent-representation.
If you don't want to access to DB at each Save and/or if you don't want to
hit DB for each obj in the graph, when you use Persist, the way to walk is
pretty easy:
don't use identity-like strategy for POID.

If for some obscure reasons you want maintain the legacy-db, without
refactoring it, even if you are writing a completely new application...
well... you are limiting yourself.
What you are calling "legacy-db" is part of a "legacy-application", no?
You are re-implementing the application, right ?
well... perhaps you should remember that the DB is part of the application.

btw, if you have a proposal or a patch, you can use our JIRA (
http://jira.nhforge.org/).

On Tue, Apr 27, 2010 at 12:52 PM, Brian Pritchard <[email protected]
> wrote:

> How can I delay insert using save?
>
> This is confusing to me because save returns the id, persist returns
> void?
>
> To me, those method signatures communicate that save ensures the id
> but persist does not.
>
> On Apr 27, 11:05 am, Fabio Maulo <[email protected]> wrote:
> > My real question is another... btw, the Save is the method who can delay
> the
> > insert.
> > Obviously if you use HiLo, Guid, Guid.conb, guid.native, sequence nobody
> > will insert the record before flush the session.
> >
> > On Tue, Apr 27, 2010 at 11:56 AM, Brian Pritchard <
> [email protected]
> >
> >
> >
> >
> >
> > > wrote:
> > > Hi Fabio,
> >
> > > What I'm trying to get at is there is a needed feature of allowing
> > > transient entities to be associated with the session without going to
> > > the db imediatly when using generated id's.
> >
> > > You say that the semantics of persist should ensure id's are
> > > available, but then why do we need it when there is save.
> >
> > > The nh recomended way is to use hilo or guids so in those cases id's
> > > will be available anyway.  But for those with legacy db's I think it
> > > is understandable that id's aren't there until you flush, if you can
> > > keep the inserts from going early you would make a lot of people
> > > happy.
> >
> > > On Apr 27, 9:42 am, Fabio Maulo <[email protected]> wrote:
> > > > Save mean Save in the UoW.
> > > > Persist is clear enough.
> >
> > > > On Tue, Apr 27, 2010 at 9:45 AM, Brian Pritchard
> > > > <[email protected]>wrote:
> >
> > > > > Maybe Persist is bad name for it as it does imply the same thing as
> > > > > Save.
> >
> > > > > Still, those using db generated id's need a way to delay inserts
> until
> > > > > flush.
> >
> > > > > What if there were a method named Associate or Attach?
> >
> > > > > On Apr 26, 11:59 pm, Fabio Maulo <[email protected]> wrote:
> > > > > > even if I think it work in the same way using session.Save, the
> > > semantic
> > > > > of
> > > > > > session.Persist should include the immediate availability of ID.
> >
> > > > > > On Mon, Apr 26, 2010 at 9:03 PM, Brian Pritchard
> > > > > > <[email protected]>wrote:
> >
> > > > > > > Hi, first like to say that I'm brand new to NHibernate and so
> far
> > > it's
> > > > > > > wonderful!
> >
> > > > > > > I'm working with a legacy oracle database that is using trigger
> > > auto-
> > > > > > > increment id's.  The TriggerIdentityGenerator works great but
> the
> > > > > > > problem is calling session.Persist() causes inserts to go the
> db
> > > > > > > immediately instead of during flush.
> >
> > > > > > > Looking through the code I found in the
> AbstractSaveEventListener
> > > > > > > class in PerformSaveOrReplicate a boolean
> > > shouldDelayIdentityInserts,
> > > > > > > that at one point (revision 3005 in case it helps) would allow
> the
> > > > > > > insert to be delayed.
> >
> > > > > > > // NH Different behavior (shouldDelayIdentityInserts=false
> anyway)
> > > > > > > //bool inTxn = source.ConnectionManager.IsInActiveTransaction;
> > > > > > > //bool shouldDelayIdentityInserts = !inTxn && !
> > > > > > > requiresImmediateIdAccess;
> > > > > > > bool shouldDelayIdentityInserts = false;
> >
> > > > > > > I changed in my local build to allow this and everything seems
> to
> > > work
> > > > > > > as I had hoped and without issue.  Although I'm still trying to
> > > figure
> > > > > > > out how to get the unit tests to run so I don't know if this
> breaks
> > > > > > > any tests.
> >
> > > > > > > Is there any reason this couldn't be reverted back?
> >
> > > > > > > Thanks,
> > > > > > > Brian Pritchard
> >
> > > > > > > --
> > > > > > > Subscription settings:
> >
> > >http://groups.google.com/group/nhibernate-development/subscribe?hl=en
> >
> > > > > > --
> > > > > > Fabio Maulo
> >
> > > > --
> > > > Fabio Maulo
> >
> > --
> > Fabio Maulo
>



-- 
Fabio Maulo

Reply via email to