From 21b2c64f374b210ed3950683064bd69d1fa575cd Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 17 Aug 2004 09:11:10 +0000 Subject: [PATCH] Documented saveOrUpdateCopy() git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@4354 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- reference/en/modules/manipulating_data.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/reference/en/modules/manipulating_data.xml b/reference/en/modules/manipulating_data.xml index af81f6f0a3..300fb7fa0f 100644 --- a/reference/en/modules/manipulating_data.xml +++ b/reference/en/modules/manipulating_data.xml @@ -484,7 +484,7 @@ sess.flush(); // changes to cat are automatically detected and persisted]]> - + Updating detached objects @@ -664,6 +664,17 @@ secondSession.saveOrUpdate(mate); // save the new instance (mate has a null id) + + The last case can be avoided by using saveOrUpdateCopy(Object o). 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, saveOrUpdate() + and saveOrUpdateCopy(). + +