[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1682) Improve the description of differences between save() and persist()

Diego Pires Plentz (JIRA) noreply at atlassian.com
Tue Mar 13 00:33:10 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1682?page=comments#action_26442 ] 

Diego Pires Plentz commented on HHH-1682:
-----------------------------------------

I found that a lot of people have the same doubt. To help to solve this issue I'm quoting Christian Bauer:

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

http://forum.hibernate.org/viewtopic.php?p=2325758&sid=a69cf62ab0451699a62552ac473356a7#2325758
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1273#action_24790

> Improve the description of differences between save() and persist()
> -------------------------------------------------------------------
>
>          Key: HHH-1682
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1682
>      Project: Hibernate3
>         Type: Improvement

>   Components: documentation
>     Versions: 3.1.2
>     Reporter: Stephen M. Wick
>     Priority: Minor

>
>
> I do not believe that the Hibernate Reference PDF differentiates between the persist() and save() methods well enough for a developer to determine which one to use and where.  This information would be extremely useful in section 10.2 "Making objects persistent" where these two methods are described.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list