In case anybody finds this thread...

persist() is well defined. It makes a transient instance persistent.
However, it doesn't guarantee that the identifier value will be assigned to
the persistent instance immediately, the assignment might happen at flush
time. The spec doesn't say that, which is the problem I have with persist().


persist() also guarantees that it will not execute an INSERT statement if it
is called outside of transaction boundaries. This is useful in long-running
conversations with an extended Session/persistence context.

A method like persist() is required.

save() does not guarantee the same, it returns an identifier, and if an
INSERT has to be executed to get the identifier (e.g. "identity" generator,
not "sequence"), this INSERT happens immediately, no matter if you are
inside or outside of a transaction. This is not good in a long-running
conversation with an extended Session/persistence context.


(Response By *christian* at last response from this post:
https://forum.hibernate.org/viewtopic.php?t=951275&highlight=difference+persist+save
)
---
Vision without action is a waking dream.
Action without vision is a nightmare.


On Fri, Nov 20, 2009 at 2:32 PM, epitka <[email protected]> wrote:

> What would be a practical example when one would user Persist, rather
> then Save? Will Persist override cascade settings on the
> relationships? I mean Save worked fine so far, but there must be a
> good reason why Persist was added.
>
> On Nov 20, 9:20 am, Fabio Maulo <[email protected]> wrote:
> > To be short...
> > Persist will persist the whole graph using cascade. Make persistent an
> > object mean know its POID.
> > Save mean Save an instance and enlist cascade actions.
> >
> > 2009/11/20 epitka <[email protected]>
> >
> >
> >
> >
> >
> > > Can somebody point me to some blog or document that discusses
> > > Session.Persist and the semantics of it. What is the difference
> > > between Session.Save and Session.Persist.
> >
> > > --
> >
> > > 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]>
> <nhusers%[email protected]<nhusers%[email protected]>>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=.
> >
> > --
> > 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=.
>
>
>

--

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=.


Reply via email to