db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1337528 - in /db/torque/torque4/trunk/torque-templates/src/main: java/org/apache/torque/templates/skipdecider/ resources/org/apache/torque/templates/om/outlets/ resources/org/apache/torque/templates/om/templates/dbObject/base/ resources/or...
Date Sat, 12 May 2012 12:55:09 GMT
Author: tfischer
Date: Sat May 12 12:55:09 2012
New Revision: 1337528

URL: http://svn.apache.org/viewvc?rev=1337528&view=rev
Log:
Fix generation of manager classes

Added:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/isCacheOnSave.vm
Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/ManagerSkipDecider.java
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/ManagerSkipDecider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/ManagerSkipDecider.java?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/ManagerSkipDecider.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/ManagerSkipDecider.java
Sat May 12 12:55:09 2012
@@ -44,6 +44,10 @@ public class ManagerSkipDecider implemen
             return false;
         }
         SourceElement sourceElement = controllerState.getSourceElement();
+        if ("false".equals(sourceElement.getAttribute("useManagers")))
+        {
+            return false;
+        }
         List<SourceElement> primaryKeyColumns
                 = sourceElement.getChild(TableChildElementName.PRIMARY_KEYS)
                     .getChildren(TorqueSchemaElementName.COLUMN);

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
Sat May 12 12:55:09 2012
@@ -146,6 +146,10 @@
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.objectBeanMethods"/>
     </mergepoint>
+    <mergepoint name="isCacheOnSave">
+      <action xsi:type="applyAction"
+          outlet="torque.om.dbObject.base.isCacheOnSave"/>
+    </mergepoint>
     <mergepoint name="equalsHashCode">
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.equalsHashCode"/>
@@ -396,6 +400,11 @@
       path="dbObject/base/bean/objectBeanMethods.vm">
   </outlet>
 
+  <outlet name="torque.om.dbObject.base.isCacheOnSave"
+      xsi:type="velocityOutlet"
+      path="dbObject/base/isCacheOnSave.vm">
+  </outlet>
+
   <outlet name="torque.om.dbObject.base.equalsHashCode"
       xsi:type="velocityOutlet"
       path="dbObject/base/equalsHashCode.vm">

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
Sat May 12 12:55:09 2012
@@ -87,7 +87,7 @@ $torqueGen.mergepoint("classJavadoc")
 #end
 public abstract class $baseDbObjectClassName $extendsBaseClass
     implements ##
-#if ($torqueGen.booleanOption("torque.om.save.addSaveMethodsInDbObjects"))
+#if ($addSaveMethods == true && $saveMethodsInDbObjects == "true")
 Persistent, ##
 #end
 Serializable##
@@ -157,6 +157,9 @@ $torqueGen.mergepoint("tableMapGetter")
 #if ($torqueGen.booleanOption("torque.om.generateBeans"))
 $torqueGen.mergepoint("objectBeanMethods")
 #end
+#if (${useManagers} == "true")
+$torqueGen.mergepoint("isCacheOnSave")
+#end
 
 $torqueGen.mergepoint("toString")
 $torqueGen.mergepoint("equalsHashCode")

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm
Sat May 12 12:55:09 2012
@@ -29,6 +29,9 @@
 #set ( $silentDbFetch = $torqueGen.booleanOption("torque.om.silentDbFetch") )
 #set ( $foreignKeyElement = $torqueGen.getParent() )
 #set ( $foreignTableElement = $foreignKeyElement.getChild("table") )
+#if (${foreignTableElement.getAttribute('useManagers')} != "")
+  #set ($useManagers = ${foreignTableElement.getAttribute('useManagers')})
+#end
 #set ( $foreignTablePeerClass = "${foreignTableElement.getAttribute('peerPackage')}.${foreignTableElement.getAttribute('peerClassName')}"
)
 #set ( $foreignTableManagerClass = "${foreignTableElement.getAttribute('managerPackage')}.${foreignTableElement.getAttribute('managerClassName')}"
)
 #set ( $and = " && " )
@@ -48,13 +51,13 @@
     #set ( $conditional = "$conditional${and}!org.apache.commons.lang.ObjectUtils.equals(this.${localColumnField},
null)" )
   #end
   #if ($arglist != "" )
-    #if ($torqueGen.booleanOption("torque.om.useManagers"))
+    #if (${useManagers} == "true")
       #set ( $arglist = "${arglist}, SimpleKey.keyFor(this.$localColumnField)" )
     #else
       #set ( $arglist = "${arglist}, this.$localColumnField" )
     #end
   #else
-    #if ($torqueGen.booleanOption("torque.om.useManagers"))
+    #if (${useManagers} == "true")
       #set ( $arglist = "SimpleKey.keyFor(this.$localColumnField)" )
     #else
       #set ( $arglist = "this.$localColumnField" )
@@ -83,14 +86,14 @@
         if ($field == null$conditional)
         {
   #if ($argsize > 1)
-    #if ($torqueGen.booleanOption("torque.om.useManagers"))
+    #if (${useManagers} == "true")
             SimpleKey[] keys = { $arglist };
             $field = ${foreignTableManagerClass}.getInstance(new ComboKey(keys));
     #else
             $field = ${foreignTablePeerClass}.retrieveByPK($arglist);
     #end
   #else
-    #if ($torqueGen.booleanOption("torque.om.useManagers"))
+    #if (${useManagers} == "true")
             $field = ${foreignTableManagerClass}.getInstance($arglist);
     #else
             $field = ${foreignTablePeerClass}.retrieveByPK(SimpleKey.keyFor($arglist));
@@ -127,7 +130,7 @@
         if ($field == null$conditional)
         {
       #if ($argsize > 1)
-        #if ($torqueGen.booleanOption("torque.om.useManagers"))
+        #if (${useManagers} == "true")
             SimpleKey[] keys = { $arglist };
             ComboKey comboid = new ComboKey(keys);
 
@@ -141,7 +144,7 @@
             $field = ${foreignTablePeerClass}.retrieveByPK($arglist, connection);
         #end
       #else
-        #if ($torqueGen.booleanOption("torque.om.useManagers"))
+        #if (${useManagers} == "true")
             $field = ${foreignTableManagerClass}.getCachedInstance($arglist);
             if ($field == null)
             {

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/isCacheOnSave.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/isCacheOnSave.vm?rev=1337528&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/isCacheOnSave.vm
(added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/isCacheOnSave.vm
Sat May 12 12:55:09 2012
@@ -0,0 +1,31 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+######
+##
+## version $Id: savingField.vm 1331196 2012-04-27 02:56:12Z tfischer $
+##
+## This template creates the isCacheOnSave method for a BaseDBObject.
+##
+    /**
+     * Specify whether to cache the object after saving to the db.
+     * This method returns true
+     */
+    protected boolean isCacheOnSave()
+    {
+        return true;
+    }

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
Sat May 12 12:55:09 2012
@@ -174,7 +174,7 @@
                 {
                     ${peerClassName}.doUpdate($toSaveVariable, con);
                 }
-#if ($torqueGen.booleanOption("torque.om.useManagers"))
+#if (${useManagers} == "true")
   #set ( $primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column")
)
   #if ( $primaryKeyColumnElements.size() != 0)
                 if (isCacheOnSave())

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm?rev=1337528&r1=1337527&r2=1337528&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm
Sat May 12 12:55:09 2012
@@ -31,13 +31,13 @@ import java.util.List;
 
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.manager.AbstractBaseManager;
 import org.apache.torque.manager.CacheListener;
 import org.apache.torque.manager.MethodResultCache;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
 import org.apache.torque.om.Persistent;
-import org.apache.torque.util.Criteria;
 
 #if ($baseManagerPackage != $managerPackage)
 import ${managerPackage}.${managerClassName};
@@ -317,12 +317,11 @@ $torqueGen.mergepoint("serialVersionUid"
     protected boolean existsImpl(${dbObjectClassName} om)
         throws TorqueException
     {
-        Criteria crit = ${peerClassName}
-            .buildCriteria((${dbObjectClassName})om);
+        Criteria crit = ${peerClassName}.buildSelectCriteria(om);
         return ${peerClassName}.doSelect(crit).size() > 0;
     }
 
-    protected Persistent retrieveStoredOM(ObjectKey id)
+    protected ${dbObjectClassName} retrieveStoredOM(ObjectKey id)
         throws TorqueException
     {
         return ${peerClassName}.retrieveByPK(id);



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