Documented saveOrUpdateCopy()
git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@4354 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
458a918ea9
commit
21b2c64f37
|
@ -484,7 +484,7 @@ sess.flush(); // changes to cat are automatically detected and persisted]]></pr
|
|||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="manipulatingdata-updating-detached">
|
||||
<sect2 id="manipulatingdata-updating-detached" revision="1">
|
||||
<title>Updating detached objects</title>
|
||||
|
||||
<para>
|
||||
|
@ -664,6 +664,17 @@ secondSession.saveOrUpdate(mate); // save the new instance (mate has a null id)
|
|||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
The last case can be avoided by using <literal>saveOrUpdateCopy(Object o)</literal>. This method
|
||||
copies the state of the given object onto the persistent object with the same identifier. If
|
||||
there is no persistent instance currently associated with the session, it will be loaded.
|
||||
The method return the persistent instance. If the given instance is unsaved or does not
|
||||
exist in the database, Hibernate will save it and return it as a newly persistent instance.
|
||||
Otherwise, the given instance does not become associated with the session. In most
|
||||
applications with detached objects, you need both methods, <literal>saveOrUpdate()</literal>
|
||||
and <literal>saveOrUpdateCopy()</literal>.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="manipulatingdata-update-lock">
|
||||
|
|
Loading…
Reference in New Issue