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 tf...@apache.org on 2010/10/28 21:08:55 UTC

svn commit: r1028435 - in /db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base: buildCriteria.vm buildSelectCriteria.vm

Author: tfischer
Date: Thu Oct 28 19:08:55 2010
New Revision: 1028435

URL: http://svn.apache.org/viewvc?rev=1028435&view=rev
Log:
- restore the generation of buildCriteria(DbObject) as needed by the managers
- improved generated javadoc

Modified:
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm?rev=1028435&r1=1028434&r2=1028435&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm Thu Oct 28 19:08:55 2010
@@ -27,7 +27,12 @@
 ## The options and the attributes of the current source element must be set
 ## as velocity variables.  
 ##
-    /** Build a Criteria object from an ObjectKey */
+    /** 
+     * Build a Criteria object which selects all objects which have a given
+     * primary key.
+     *
+     * @param pk the primary key value to build the criteria from, not null.
+     */
     public static Criteria buildCriteria(ObjectKey pk)
     {
         Criteria criteria = new Criteria();
@@ -48,7 +53,15 @@
         return criteria;
      }
 
-    /** Build a Criteria object from the data object for this peer */
+    /** 
+     * Build a Criteria object from the data object for this peer.
+#set ( $primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column") )
+#if (!$idMethod.equals("none") && $primaryKeyColumnElements.size() > 1)
+     * The primary key columns are only added if the object is not new.
+#end
+     *
+     * @param obj the object to build the criteria from, not null.
+     */
     public static Criteria buildCriteria($dbObjectClassName obj)
     {
         Criteria criteria = new Criteria(DATABASE_NAME);
@@ -56,63 +69,13 @@
   #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") )
   #set ( $getter = $columnElement.getAttribute("getter") )
   #set ( $primaryKey = ($columnElement.getAttribute("primaryKey") == "true") )
-  #set ( $columnType = $columnElement.getAttribute("type") )
-  #set ( $columnSchemaType = $columnElement.getAttribute("schemaType") )
-  #set ( $columnFieldName = $columnElement.getAttribute("field") )
-  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
   #if ($primaryKey && !$idMethod.equals("none"))
         if (!obj.isNew())
         {
-    #if ($columnType == "DATE" && $columnFieldType == "java.util.Date")
-            java.util.Date $columnFieldName = obj.${getter}();
-            if ($columnFieldName != null)
-            {
-                $columnFieldName = new java.sql.Date(${columnFieldName}.getTime());
-            }
-            criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #elseif ($columnType == "TIME" && $columnFieldType == "java.util.Date")
-            java.util.Date $columnFieldName = obj.${getter}();
-            if ($columnFieldName != null)
-            {
-                $columnFieldName = new java.sql.Time(${columnFieldName}.getTime());
-            }
-            criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #elseif ($columnType == "TIMESTAMP" && $columnFieldType == "java.util.Date")
-            java.util.Date $columnFieldName = obj.${getter}();
-            if ($columnFieldName != null)
-            {
-                $columnFieldName = new java.sql.Timestamp(${columnFieldName}.getTime());
-            }
-            criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #else
             criteria.add(${peerClassName}.$peerColumnName, obj.${getter}());
-    #end
         }
   #else
-    #if ($columnType == "DATE" && $columnFieldType == "java.util.Date")
-        java.util.Date $columnFieldName = obj.${getter}();
-        if ($columnFieldName != null)
-        {
-            $columnFieldName = new java.sql.Date(${columnFieldName}.getTime());
-        }
-        criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #elseif ($columnType == "TIME" && $columnFieldType == "java.util.Date")
-        java.util.Date $columnFieldName = obj.${getter}();
-        if ($columnFieldName != null)
-        {
-            $columnFieldName = new java.sql.Time(${columnFieldName}.getTime());
-        }
-        criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #elseif ($columnType == "TIMESTAMP" && $columnFieldType == "java.util.Date")
-        java.util.Date $columnFieldName = obj.${getter}();
-        if ($columnFieldName != null)
-        {
-            $columnFieldName = new java.sql.Timestamp(${columnFieldName}.getTime());
-        }
-        criteria.add(${peerClassName}.$peerColumnName, $columnFieldName);
-    #else
         criteria.add(${peerClassName}.$peerColumnName, obj.${getter}());
-    #end
   #end
   #end
         return criteria;

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm?rev=1028435&r1=1028434&r2=1028435&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm Thu Oct 28 19:08:55 2010
@@ -27,7 +27,16 @@
 ## The options and the attributes of the current source element must be set
 ## as velocity variables.  
 ##
-    /** Build a Criteria object from the data object for this peer, skipping all binary columns */
+    /** 
+     * Build a Criteria object from the data object for this peer,
+     * skipping all binary columns.
+#set ( $primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column") )
+#if (!$idMethod.equals("none") && $primaryKeyColumnElements.size() > 1)
+     * The primary key columns are only added if the object is not new.
+#end
+     *
+     * @param obj the object to build the criteria from, not null.
+     */
     public static Criteria buildSelectCriteria($dbObjectClassName obj)
     {
         Criteria criteria = new Criteria(DATABASE_NAME);



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