You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tv...@apache.org on 2019/10/23 16:21:58 UTC
svn commit: r1868813 -
/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
Author: tv
Date: Wed Oct 23 16:21:58 2019
New Revision: 1868813
URL: http://svn.apache.org/viewvc?rev=1868813&view=rev
Log:
Fix several problems
- Velocity 2.x #set overwrites variable in any case
- $saveMethodsInDbObjects=false generated code needs to care for insert/update
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm?rev=1868813&r1=1868812&r2=1868813&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm Wed Oct 23 16:21:58 2019
@@ -36,7 +36,9 @@
#set ( $foreignTablePeerClassName = $foreignTableElement.getAttribute("peerClassName") )
#set ( $foreignDbObjectClassName = $foreignTableElement.getAttribute("dbObjectClassName") )
#set ( $foreignPrimaryKeyColumnElements = $foreignTableElement.getChild("primary-keys").getChildren("column"))
-#set ( $saveMethodsInDbObjects = $foreignTableElement.getAttribute("saveMethodsInDbObjects") )
+#if ($foreignTableElement.getAttribute("saveMethodsInDbObjects"))
+#set ($saveMethodsInDbObjects = $foreignTableElement.getAttribute("saveMethodsInDbObjects"))
+#end
#if ($foreignTableElement.getChild("primary-keys").getChildren().size() > 0)
/**
* Saves the passed collection as linked objects.
@@ -240,8 +242,15 @@
if (listIndex == -1)
{
toLinkTo.${adder}(toSaveElement);
-#if ($saveMethodsInDbObjects != "true")
- ${foreignTablePeerClassName}.doUpdate(toSaveElement, connection);
+#if ("$!saveMethodsInDbObjects" != "true")
+ if (toSaveElement.isNew())
+ {
+ ${foreignTablePeerClassName}.doInsert(toSaveElement, connection);
+ }
+ else
+ {
+ ${foreignTablePeerClassName}.doUpdate(toSaveElement, connection);
+ }
#else
toSaveElement.save(connection);
#end
@@ -259,7 +268,7 @@
toSaveElement.setModified(true);
}
#end
-#if ($saveMethodsInDbObjects != "true")
+#if ("$!saveMethodsInDbObjects" != "true")
${foreignTablePeerClassName}.doUpdate(toSaveElement, connection);
#else
toSaveElement.save(connection);
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org