db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1103517 - /db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
Date Sun, 15 May 2011 19:54:35 GMT
Author: tfischer
Date: Sun May 15 19:54:35 2011
New Revision: 1103517

URL: http://svn.apache.org/viewvc?rev=1103517&view=rev
Log:
TORQUE-119: clear alreadyInSave flag in try...finally block.
Thanks to Florian Liese for submitting the Bug and suggesting a solution.

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm?rev=1103517&r1=1103516&r2=1103517&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
Sun May 15 19:54:35 2011
@@ -129,30 +129,32 @@
         {
             return;
         }
-        alreadyInSave = true;
-#end
-        // If this object has been modified, then save it to the database.
-        if (isModified())
+        try
         {
-            if (isNew())
-            {
-                ${peerClassName}.doInsert(($dbObjectClassName) this, con);
-                setNew(false);
-            }
-            else
+            alreadyInSave = true;
+#end
+            // If this object has been modified, then save it to the database.
+            if (isModified())
             {
-                ${peerClassName}.doUpdate(($dbObjectClassName) this, con);
-            }
+                if (isNew())
+                {
+                    ${peerClassName}.doInsert(($dbObjectClassName) this, con);
+                    setNew(false);
+                }
+                else
+                {
+                    ${peerClassName}.doUpdate(($dbObjectClassName) this, con);
+                }
 #if ($torqueGen.booleanOption("torque.om.useManagers"))
   #set ( $primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column")
)
   #if ( $primaryKeyColumnElements.size() != 0)
-            if (isCacheOnSave())
-            {
-                ${managerPackage}.${managerClassName}.putInstance(this);
-            }
+                if (isCacheOnSave())
+                {
+                    ${managerPackage}.${managerClassName}.putInstance(this);
+                }
   #end
 #end
-        }
+            }
 
 #if ($complexObjectModel && $objectIsCaching)
   #set ( $referencingForeignKeyElements = $torqueGen.getChild("referencing-foreign-keys").getChildren("foreign-key")
)
@@ -167,17 +169,21 @@
       ## if the referencing table is in an external schema, field is null.
       ## In this case,skip the foolowing code
       #if ($foreignField)
-        if ($foreignField != null)
-        {
-            for (int i = 0; i < ${foreignField}.size(); i++)
+            if ($foreignField != null)
             {
-                ((${otherClassName}) ${foreignField}.get(i)).save(con);
+                for (int i = 0; i < ${foreignField}.size(); i++)
+                {
+                    ((${otherClassName}) ${foreignField}.get(i)).save(con);
+                }
             }
-        }
       #end
     #end
   #end
-        alreadyInSave = false;
+        }
+        finally
+        {
+            alreadyInSave = false;
+        }
 #end
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message