[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1273) Remove persist() on Session API

Christian Bauer (JIRA) noreply at atlassian.com
Thu Oct 12 09:05:25 EDT 2006


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

Christian Bauer commented on HHH-1273:
--------------------------------------

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.


> Remove persist() on Session API
> -------------------------------
>
>          Key: HHH-1273
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1273
>      Project: Hibernate3
>         Type: Improvement

>   Components: core, documentation
>     Reporter: Christian Bauer

>
>
> This is from a user/documentatio perspective, completely ignoring any reason on the implementation side. Stay with me.
> The persist() operation on Session is not cascaded at flush time. This is somewhat unexpected from a users point of view and very difficult to explain and understand (you need excellent knowledge of flushing and cascading). Reason #1 for removal.
> The persist() operation in general does not return a database identifier. This is surprising, as the JPA spec clearly requires a persistent instance to have a database identifier value. Since persist() makes instances persistent, it has to have the same semantics for assigning identifiers as save(). Hence, I expect that once this mismatch is resolved in the expert group, the persist() method will return a database identifier. Everything else doesn't make much sense, given the current specification and documentation. Conclusion is that persist() will have the same signature as save(). Reason #2 for removal.
> To document persist() properly I need a reason for its existence. Right now I'm telling readers/users to ignore it on the Session API, because it only complicates the situation with no benefit.

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