db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1028130 [5/6] - in /db/torque/torque4/branches/trunk-without-village: torque-runtime/ torque-runtime/src/main/java/org/apache/torque/map/ torque-runtime/src/main/java/org/apache/torque/oid/ torque-runtime/src/main/java/org/apache/torque/om...
Date Wed, 27 Oct 2010 22:52:18 GMT
Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.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/dbObject/base/primaryKeyMethods.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm Wed Oct 27 22:52:15 2010
@@ -43,40 +43,40 @@
 #set ( $primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column"))
 #if ($primaryKeyColumnElements.size() == 1)
   #set ( $columnElement = $primaryKeyColumnElements.get(0) )
-  #set ( $field = $columnElement.getAttribute("field") )
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $columnField = $columnElement.getAttribute("field") )
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
   #set ( $setter = $columnElement.getAttribute("setter") )
   #set ( $number = $columnElement.getAttribute("number") )
   #set ( $primitive = $columnElement.getAttribute("primitive") )
     /**
      * Set the PrimaryKey using ObjectKey.
      *
-     * @param key $field ObjectKey
+     * @param key $columnField ObjectKey
      */
     public void setPrimaryKey(ObjectKey key)
         $throwsClause
     {
-  #if($fieldType == "java.math.BigDecimal")
+  #if($columnFieldType == "java.math.BigDecimal")
         ${setter}(((NumberKey) key).getBigDecimal());
   #elseif ($number == "true")
     #if ($primitive == "true")
-        ${setter}(((NumberKey) key).${fieldType}Value());
+        ${setter}(((NumberKey) key).${columnFieldType}Value());
     #else
-      #if ($fieldType == "Integer")
+      #if ($columnFieldType == "Integer")
         #set ( $valueMethod = "intValue")
       #else
-        #set ( $valueMethod = "${fieldType.substring(0,1).toLowerCase()}${fieldType.substring(1)}Value" )
+        #set ( $valueMethod = "${columnFieldType.substring(0,1).toLowerCase()}${columnFieldType.substring(1)}Value" )
       #end
-        ${setter}(new ${fieldType}(((NumberKey) key).${valueMethod}()));
+        ${setter}(new ${columnFieldType}(((NumberKey) key).${valueMethod}()));
     #end
-  #elseif($fieldType == "String")
+  #elseif($columnFieldType == "String")
         ${setter}(key.toString());
-  #elseif($fieldType == "java.util.Date")
+  #elseif($columnFieldType == "java.util.Date")
         ${setter}(((DateKey) key).getDate());
-  #elseif($fieldType == "Boolean" || $fieldType == "boolean")
+  #elseif($columnFieldType == "Boolean" || $columnFieldType == "boolean" )
         ${setter}(((BooleanKey) key).getBoolean());
   #else
-        ${setter}(($fieldType) key);
+        ${setter}(($columnFieldType) key);
   #end
     }
 
@@ -87,30 +87,30 @@
      */
     public void setPrimaryKey(String key) $throwsClause
     {
-  #if($fieldType == "java.math.BigDecimal")
-        ${setter}(new $fieldType(key));
-  #elseif ($fieldType == "short")
+  #if($columnFieldType == "java.math.BigDecimal")
+        ${setter}(new $columnFieldType(key));
+  #elseif ($columnFieldType == "short")
         ${setter}(Short.parseShort(key));
-  #elseif($fieldType == "int")
+  #elseif($columnFieldType == "int")
         ${setter}(Integer.parseInt(key));
-  #elseif($fieldType == "long")
+  #elseif($columnFieldType == "long")
         ${setter}(Long.parseLong(key));
-  #elseif($fieldType == "java.math.BigDecimal")
-        ${setter}(new $fieldType(key));
-  #elseif($fieldType == "byte")
+  #elseif($columnFieldType == "java.math.BigDecimal")
+        ${setter}(new $columnFieldType(key));
+  #elseif($columnFieldType == "byte")
         ${setter}(Byte.parseByte(key));
-  #elseif($fieldType == "float")
+  #elseif($columnFieldType == "float")
         ${setter}(Float.parseFloat(key));
-  #elseif($fieldType == "double")
+  #elseif($columnFieldType == "double")
         ${setter}(Double.parseDouble(key));
   #elseif ($number == "true" && ($primitive != "true"))
-        ${setter}(new ${fieldType}(key));
-  #elseif($fieldType == "String")
+        ${setter}(new ${columnFieldType}(key));
+  #elseif($columnFieldType == "String")
         ${setter}(key);
-  #elseif($fieldType == "java.util.Date")
-        ${setter}(new ${fieldType}(key));
+  #elseif($columnFieldType == "java.util.Date")
+        ${setter}(new ${columnFieldType}(key));
   #else
-        ${setter}(($fieldType) key);
+        ${setter}(($columnFieldType) key);
   #end
     }
 
@@ -129,32 +129,32 @@
         SimpleKey[] keys = (SimpleKey[]) key.getValue();
   #set ($i = 0)
   #foreach ($columnElement in $primaryKeyColumnElements)
-    #set ( $field = $columnElement.getAttribute("field") )
-    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+    #set ( $columnField = $columnElement.getAttribute("field") )
+    #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
     #set ( $setter = $columnElement.getAttribute("setter") )
     #set ( $number = $columnElement.getAttribute("number") )
     #set ( $primitive = $columnElement.getAttribute("primitive") )
-    #if($fieldType == "java.math.BigDecimal")
+    #if($columnFieldType == "java.math.BigDecimal")
         ${setter}(((NumberKey) keys[$i]).getBigDecimal());
     #elseif ($number == "true")
       #if ($primitive == "true")
-        ${setter}(((NumberKey) keys[$i]).${fieldType}Value());
+        ${setter}(((NumberKey) keys[$i]).${columnFieldType}Value());
       #else
-        #if ($fieldType == "Integer")
+        #if ($columnFieldType == "Integer")
           #set ( $valueMethod = "intValue")
         #else
-          #set ( $valueMethod = "${fieldType.substring(0,1).toLowerCase()}${fieldType.substring(1)}Value" )
+          #set ( $valueMethod = "${columnFieldType.substring(0,1).toLowerCase()}${columnFieldType.substring(1)}Value" )
         #end
-        ${setter}(new ${fieldType}(((NumberKey) keys[$i]).${valueMethod}()));
+        ${setter}(new ${columnFieldType}(((NumberKey) keys[$i]).${valueMethod}()));
       #end
-    #elseif($fieldType == "String")
+    #elseif($columnFieldType == "String")
         ${setter}(keys[$i].toString());
-    #elseif($fieldType == "Date")
+    #elseif($columnFieldType == "Date")
         ${setter}(((DateKey) keys[$i]).getDate());
-    #elseif($fieldType == "Boolean" || $fieldType == "boolean")
+    #elseif($columnFieldType == "Boolean" || $columnFieldType == "boolean")
         ${setter}(((BooleanKey) keys[$i]).getBoolean());
     #else
-        ${setter}(($fieldType) keys[$i]);
+        ${setter}(($columnFieldType) keys[$i]);
     #end
     #set ( $i = $i + 1 )
   #end
@@ -165,15 +165,15 @@
      *
   #set ( $argList = "" )
   #foreach ($columnElement in $primaryKeyColumnElements)
-    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-    #set ( $field = $columnElement.getAttribute("field") )
+    #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+    #set ( $columnField = $columnElement.getAttribute("field") )
     #set ( $clo=$col.UncapitalisedJavaName )
     #set ( $cjtype= $col.JavaNative )
     #if ($argList != "")
       #set ( $argList = "${argList}, " )
     #end
-    #set ( $argList = "${argList}$fieldType $field")
-     * @param $fieldType $field
+    #set ( $argList = "${argList}$columnFieldType $columnField")
+     * @param $columnFieldType $columnField
   #end
      */
     public void setPrimaryKey($argList)
@@ -181,8 +181,8 @@
     {
   #foreach ($columnElement in $primaryKeyColumnElements)
     #set ( $setter = $columnElement.getAttribute("setter") )
-    #set ( $field = $columnElement.getAttribute("field") )
-        ${setter}($field);
+    #set ( $columnField = $columnElement.getAttribute("field") )
+        ${setter}($columnField);
   #end
     }
 

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.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/dbObject/base/saveMethods.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm Wed Oct 27 22:52:15 2010
@@ -158,15 +158,15 @@
     #if ( !($thisTableName.equals($otherTableName)) )
       #set ( $otherClassName = $otherTable.getAttribute("baseDbObjectClassName") )
       #set ( $relCol = "" )
-      #set ( $field = $referencingForeignKeyElement.getChild("foreign-field").getAttribute("field"))
+      #set ( $foreignField = $referencingForeignKeyElement.getChild("foreign-field").getAttribute("field"))
       ## if the referencing table is in an external schema, field is null.
       ## In this case,skip the foolowing code
-      #if ($field)
-            if ($field != null)
+      #if ($foreignField)
+            if ($foreignField != null)
             {
-                for (int i = 0; i < ${field}.size(); i++)
+                for (int i = 0; i < ${foreignField}.size(); i++)
                 {
-                    ((${otherClassName}) ${field}.get(i)).save(con);
+                    ((${otherClassName}) ${foreignField}.get(i)).save(con);
                 }
             }
       #end

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.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/dbObject/base/toString.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm Wed Oct 27 22:52:15 2010
@@ -29,11 +29,11 @@
         str.append("$dbObjectClassName:\n");
 #set ( $columnElements = $torqueGen.getChildren("column") )
 #foreach ($columnElement in $columnElements)
-  #set ( $field = $columnElement.getAttribute("field") )
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $columnField = $columnElement.getAttribute("field") )
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
   #set ( $getter = $columnElement.getAttribute("getter") )
-        str.append("$field = ")
-  #if ( $fieldType == "byte[]" )
+        str.append("$columnField = ")
+  #if ( $columnFieldType == "byte[]" )
            .append("<binary>")
   #else
            .append(${getter}())

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.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/general/createDbObjectInstance.vm?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm Wed Oct 27 22:52:15 2010
@@ -0,0 +1,46 @@
+## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $
+##
+## This template defines how to create instances of the data object.
+## If the class is not abstract, the constructor is invoked,
+## otherwise it is created using reflection.
+## The instance is stored in a field which is defined in the table.
+##
+## This template needs to operate on a table element transformed by the 
+## OmTransformer 
+##
+#if ($abstract == "true")
+        $dbObjectClassName $field;
+        try
+        {
+            $field = ($dbObjectClassName) ${peerClassName}.getOMClass().newInstance();
+        }
+        catch (InstantiationException e)
+        {
+            throw new TorqueException(e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new TorqueException(e);
+        }
+#else
+        $dbObjectClassName $field = new ${dbObjectClassName}();
+#end

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.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/general/setterMethodEnd.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm Wed Oct 27 22:52:15 2010
@@ -35,14 +35,16 @@
     #set ( $foreignColumnGetter = $foreignColumnElement.getAttribute("getter") )
     #set ( $localFieldElement = $foreignKeyElement.getChild("local-field") )
     #set ( $localReferenceFieldName = $localFieldElement.getAttribute("field") )
-    #if ($foreignColumnElement.getAttribute("primitive") == "true")
+    #if ( $localReferenceFieldName )
+      #if ($foreignColumnElement.getAttribute("primitive") == "true")
         if ($localReferenceFieldName != null && ${localReferenceFieldName}.${foreignColumnGetter}() != v)
-    #else
+      #else
         if ($localReferenceFieldName != null && !org.apache.commons.lang.ObjectUtils.equals(${localReferenceFieldName}.${foreignColumnGetter}(), v))
-    #end
+      #end
         {
             $localReferenceFieldName = null;
         }
+    #end
   #end
 
   ##

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.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/manager/base/baseManager.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm Wed Oct 27 22:52:15 2010
@@ -132,7 +132,7 @@ $torqueGen.mergepoint("serialVersionUid"
 #set ($primaryKeyColumnElements = $torqueGen.getChild("primary-keys").getChildren("column"))
 #if ($primaryKeyColumnElements.size() == 1)
   #set ($primaryKeyColumnElement = $primaryKeyColumnElements.get(0))
-  #set ($fieldType = $primaryKeyColumnElement.getAttribute("fieldType"))
+  #set ($columnFieldType = $primaryKeyColumnElement.getAttribute("fieldType"))
     /**
      * Static accessor for the @see #getInstanceImpl(ObjectKey).
      *
@@ -140,7 +140,7 @@ $torqueGen.mergepoint("serialVersionUid"
      * @return a <code>${dbObjectClassName}</code> value
      * @exception TorqueException if an error occurs
      */
-    public static ${dbObjectClassName} getInstance($fieldType id)
+    public static ${dbObjectClassName} getInstance($columnFieldType id)
         throws TorqueException
     {
         return getManager().getInstanceImpl(SimpleKey.keyFor(id));
@@ -155,7 +155,7 @@ $torqueGen.mergepoint("serialVersionUid"
      * @return a <code>${dbObjectClassName}</code> value
      * @exception TorqueException if an error occurs
      */
-    public static ${dbObjectClassName} getInstance($fieldType id, boolean fromCache)
+    public static ${dbObjectClassName} getInstance($columnFieldType id, boolean fromCache)
         throws TorqueException
     {
         return getManager().getInstanceImpl(SimpleKey.keyFor(id), fromCache);

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapBuilder/doBuild.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/mapBuilder/doBuild.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapBuilder/doBuild.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapBuilder/doBuild.vm Wed Oct 27 22:52:15 2010
@@ -106,7 +106,7 @@
   #set ( $columnName = $columnElement.getAttribute("name") )
   #set ( $javaName = $columnElement.getAttribute("javaName") )
   #set ( $type = $columnElement.getAttribute("type") )
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
   #set ( $sampleObject = $columnElement.getAttribute("sampleObject") )
   #set ( $primitive = $columnElement.getAttribute("primitive") )
   #set ( $primaryKey = $columnElement.getAttribute("primaryKey") )
@@ -129,8 +129,8 @@
         cMap.setJavaName("$javaName");
         cMap.setAutoIncrement($autoIncrement);
         cMap.setProtected($protected);
-  #if ($fieldType)
-        cMap.setJavaType( "${fieldType}" );
+  #if ($columnFieldType)
+        cMap.setJavaType( "${columnFieldType}" );
   #end
   #if ($columnDescription)
         cMap.setDescription("${columnDescription}");

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapInit/baseMapInit.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/mapInit/baseMapInit.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapInit/baseMapInit.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapInit/baseMapInit.vm Wed Oct 27 22:52:15 2010
@@ -42,7 +42,8 @@ public class ${mapInitClassName}
     public static final void init()
         throws TorqueException
     {
-#set ( $tableElements = $torqueGen.getChildren("table") )
+#set ( $allTableElement = $torqueGen.getChild("all-tables") )
+#set ( $tableElements = $allTableElement.getChildren("table") )
 #foreach ( $tableElement in $tableElements )
   #set ( $mapBuilderClassName = $tableElement.getAttribute("mapBuilderClassName") )
   #set ( $mapBuilderPackage = $tableElement.getAttribute("mapBuilderPackage") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.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/basePeer.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm Wed Oct 27 22:52:15 2010
@@ -53,17 +53,14 @@ $torqueGen.mergepoint("classMethods")
 $torqueGen.mergepoint("resultSet2Objects")
 $torqueGen.mergepoint("addSelectColumns")
 $torqueGen.mergepoint("correctBooleans")
-$torqueGen.mergepoint("row2Object")
-$torqueGen.mergepoint("populateObject")
 $torqueGen.mergepoint("doSelect")
-$torqueGen.mergepoint("doSelectVillageRecords")
-$torqueGen.mergepoint("populateObjects")
 $torqueGen.mergepoint("getOMClass")
 $torqueGen.mergepoint("doInsert")
 $torqueGen.mergepoint("doUpdate")
 $torqueGen.mergepoint("doDelete")
 $torqueGen.mergepoint("buildCriteria")
 $torqueGen.mergepoint("buildSelectCriteria")
+$torqueGen.mergepoint("buildColumnValues")
 $torqueGen.mergepoint("retrieveByPK")
 $torqueGen.mergepoint("retrieveByPKs")
 #if ($complexObjectModel == "true")
@@ -73,4 +70,5 @@ $torqueGen.mergepoint("doSelectJoinAllEx
 $torqueGen.mergepoint("getTableMap")
 $torqueGen.mergepoint("setDbName")
 $torqueGen.mergepoint("extensions")
+$torqueGen.mergepoint("recordMapper")
 }

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.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/buildColumnValues.vm?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.vm (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.vm Wed Oct 27 22:52:15 2010
@@ -0,0 +1,152 @@
+## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $
+##
+## Creates the getColumnValue method in the base peer class. 
+## 
+## This template expects the current source element to be a "table" element 
+## from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The options and the attributes of the current source element must be set
+## as velocity variables.  
+##
+    /** 
+     * Returns the contents of the object as ColumnValues object
+     *
+     * @throws TorqueException if the table map cannot be retrieved
+     *         (should not happen).
+     */
+    public static ColumnValues buildColumnValues($dbObjectClassName $field)
+            throws TorqueException
+    {
+        ColumnValues columnValues = new ColumnValues(getTableMap());
+#foreach ($columnElement in $torqueGen.getChildren("column"))
+  #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 (!${field}.isNew())
+        {
+    #if ($columnType == "DATE" && $columnFieldType == "java.util.Date")
+            java.util.Date $columnFieldName = ${field}.${getter}();
+            if ($columnFieldName != null)
+            {
+                $columnFieldName = new java.sql.Date(${columnFieldName}.getTime());
+            }
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue($columnFieldName, Types.DATE));
+    #elseif ($columnType == "TIME" && $columnFieldType == "java.util.Date")
+            java.util.Date $columnFieldName = ${field}.${getter}();
+            if ($columnFieldName != null)
+            {
+                $columnFieldName = new java.sql.Time(${columnFieldName}.getTime());
+            }
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue($columnFieldName, Types.TIME));
+    #elseif ($columnType == "TIMESTAMP" && $columnFieldType == "java.util.Date")
+            java.util.Date $columnFieldName = ${field}.${getter}();
+            if ($columnFieldName != null)
+            {
+                $columnFieldName = new java.sql.Timestamp(${columnFieldName}.getTime());
+            }
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue($columnFieldName, Types.TIMESTAMP));
+    #elseif ($columnType == "BOOLEANCHAR" && $columnFieldType.equalsIgnoreCase("boolean"))
+            String $columnFieldName = Boolean.TRUE.equals(${field}.${getter}())
+                                        ? "Y"
+                                        : "N";
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue($columnFieldName, Types.CHAR));
+    #elseif ($columnType == "BOOLEANINT" && $columnFieldType.equalsIgnoreCase("boolean"))
+            Integer $columnFieldName = Boolean.TRUE.equals(${field}.${getter}())
+                                        ? new Integer(1)
+                                        : new Integer(0);
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue($columnFieldName, Types.INTEGER));
+    #else
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue(
+                        ${field}.${getter}(),
+                        ${columnSchemaType.getJdbcType()}));
+    #end
+        }
+  #else
+    #if ($columnType == "DATE" && $columnFieldType == "java.util.Date")
+        java.util.Date $columnFieldName = ${field}.${getter}();
+        if ($columnFieldName != null)
+        {
+            $columnFieldName = new java.sql.Date(${columnFieldName}.getTime());
+        }
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue($columnFieldName, Types.DATE));
+    #elseif ($columnType == "TIME" && $columnFieldType == "java.util.Date")
+        java.util.Date $columnFieldName = ${field}.${getter}();
+        if ($columnFieldName != null)
+        {
+            $columnFieldName = new java.sql.Time(${columnFieldName}.getTime());
+        }
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue($columnFieldName, Types.TIME));
+    #elseif ($columnType == "TIMESTAMP" && $columnFieldType == "java.util.Date")
+        java.util.Date $columnFieldName = ${field}.${getter}();
+        if ($columnFieldName != null)
+        {
+            $columnFieldName = new java.sql.Timestamp(${columnFieldName}.getTime());
+        }
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue($columnFieldName, Types.TIMESTAMP));
+    #elseif ($columnType == "BOOLEANCHAR" && $columnFieldType.equalsIgnoreCase("boolean"))
+        String $columnFieldName = Boolean.TRUE.equals(${field}.${getter}())
+                                    ? "Y"
+                                    : "N";
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue($columnFieldName, Types.CHAR));
+    #elseif ($columnType == "BOOLEANINT" && $columnFieldType.equalsIgnoreCase("boolean"))
+        Integer $columnFieldName = Boolean.TRUE.equals(${field}.${getter}())
+                                    ? new Integer(1)
+                                    : new Integer(0);
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue($columnFieldName, Types.INTEGER));
+    #else
+        columnValues.put(
+                ${peerClassName}.$peerColumnName,
+                new JdbcTypedValue(
+                    ${field}.${getter}(),
+                    ${columnSchemaType.getJdbcType()}));
+    #end
+  #end
+#end
+        return columnValues;
+    }

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=1028130&r1=1028129&r2=1028130&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 Wed Oct 27 22:52:15 2010
@@ -56,13 +56,63 @@
   #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=1028130&r1=1028129&r2=1028130&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 Wed Oct 27 22:52:15 2010
@@ -33,10 +33,10 @@
         Criteria criteria = new Criteria(DATABASE_NAME);
 #foreach ($columnElement in $torqueGen.getChildren("column"))
   #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") ) 
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") ) 
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") ) 
   #set ( $getter = $columnElement.getAttribute("getter") ) 
   #set ( $primaryKey = ($columnElement.getAttribute("primaryKey") == "true") )
-  #if ( $fieldType != "byte[]" )
+  #if ( $columnFieldType != "byte[]" )
     #if ($primaryKey && !$idMethod.equals("none"))
         if (!obj.isNew())
         {

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.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/dbObjectClassConstants.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm Wed Oct 27 22:52:15 2010
@@ -45,7 +45,7 @@
   #else
     #set ($quote = '"')
   #end
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
   #foreach ($inheritanceElement in $inheritanceElements)
     #set ( $key = $inheritanceElement.getAttribute("key") )
     #set ( $class = $inheritanceElement.getAttribute("class") )
@@ -53,7 +53,7 @@
     #set ( $classkeyConstant = $inheritanceElement.getAttribute("classkeyConstant") )
     #set ( $classnameConstant = $inheritanceElement.getAttribute("classnameConstant") )
     /** A key representing a particular subclass */
-    public static final $fieldType $classkeyConstant =
+    public static final $columnFieldType $classkeyConstant =
         $quote$key$quote;
 
     /** A class that can be returned by this peer. */

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.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/doDelete.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm Wed Oct 27 22:52:15 2010
@@ -36,7 +36,23 @@
      */
      public static void doDelete(Criteria criteria) throws TorqueException
      {
-         ${peerClassName}.doDelete(criteria, (Connection) null);
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    DATABASE_NAME,
+                    true);
+            ${peerClassName}.doDelete(criteria, connection);
+            Transaction.commit(connection);
+            connection = null;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
      }
 
     /**
@@ -56,14 +72,7 @@
 
         setDbName(criteria);
 
-        if (con == null)
-        {
-            BasePeer.doDelete(criteria, TABLE_NAME);
-        }
-        else
-        {
-            BasePeer.doDelete(criteria, TABLE_NAME, con);
-        }
+        BasePeer.doDelete(criteria, TABLE_NAME, con);
      }
 
     /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.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/doInsert.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm Wed Oct 27 22:52:15 2010
@@ -28,46 +28,6 @@
 ## as velocity variables.  
 ##
     /**
-     * Method to do inserts.
-     *
-     * @param criteria object used to create the INSERT statement.
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
-     */
-    public static ObjectKey doInsert(Criteria criteria)
-        throws TorqueException
-    {
-        return ${peerClassName}.doInsert(criteria, (Connection) null);
-    }
-
-    /**
-     * Method to do inserts.  This method is to be used during a transaction,
-     * otherwise use the doInsert(Criteria) method.  It will take care of
-     * the connection details internally.
-     *
-     * @param criteria object used to create the INSERT statement.
-     * @param con the connection to use
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
-     */
-    public static ObjectKey doInsert(Criteria criteria, Connection con)
-        throws TorqueException
-    {
-        ${peerClassName}.correctBooleans(criteria);
-
-        setDbName(criteria);
-
-        if (con == null)
-        {
-            return BasePeer.doInsert(criteria);
-        }
-        else
-        {
-            return BasePeer.doInsert(criteria, con);
-        }
-    }
-
-    /**
      * Method to do inserts
      *
      * @throws TorqueException Any exceptions caught during processing will be
@@ -76,10 +36,10 @@
     public static void doInsert($dbObjectClassName obj) throws TorqueException
     {
   #if ($idMethod.equals("none") || $torqueGen.getChild("primary-keys").getChildren("column").isEmpty())
-        ${peerClassName}.doInsert(${peerClassName}.buildCriteria(obj));
+        ${peerClassName}.doInsert(${peerClassName}.buildColumnValues(obj));
   #else
         obj.setPrimaryKey(${peerClassName}.doInsert(
-                ${peerClassName}.buildCriteria(obj)));
+                ${peerClassName}.buildColumnValues(obj)));
   #end
         obj.setNew(false);
         obj.setModified(false);
@@ -99,10 +59,10 @@
         throws TorqueException
     {
   #if ($idMethod.equals("none") || $torqueGen.getChild("primary-keys").getChildren("column").isEmpty())
-        ${peerClassName}.doInsert(${peerClassName}.buildCriteria(obj), con);
+        ${peerClassName}.doInsert(${peerClassName}.buildColumnValues(obj), con);
   #else
         obj.setPrimaryKey(${peerClassName}.doInsert(
-                ${peerClassName}.buildCriteria(obj), con));
+                ${peerClassName}.buildColumnValues(obj), con));
   #end
         obj.setNew(false);
         obj.setModified(false);

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.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/doSelect.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm Wed Oct 27 22:52:15 2010
@@ -28,42 +28,66 @@
 ## as velocity variables.  
 ##
     /**
-     * Method to do selects.
+     * Selects ${dbObjectClassName} objects from a database.
      *
      * @param criteria object used to create the SELECT statement.
-     * @return List of selected Objects
+     * @return the List of selected Objects, not null.
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static List<${dbObjectClassName}> doSelect(Criteria criteria) throws TorqueException
+    public static List<${dbObjectClassName}> doSelect(Criteria criteria)
+            throws TorqueException
     {
-        return ${peerClassName}.populateObjects(
-                ${peerClassName}.doSelectVillageRecords(criteria));
+        if (criteria.getSelectColumns().size() == 0)
+        {
+            ${peerClassName}.addSelectColumns(criteria);
+        }
+        setDbName(criteria);
+
+        return ${peerClassName}.doSelect(
+            criteria, 
+            new $recordMapperClass(),
+            getTableMap());
     }
 
     /**
-     * Method to do selects within a transaction.
+     * Selects ${dbObjectClassName} objects from a database
+     * within a transaction.
      *
      * @param criteria object used to create the SELECT statement.
-     * @param con the connection to use
+     * @param connection the connection to use, not null.
      * @return List of selected Objects
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static List<${dbObjectClassName}> doSelect(Criteria criteria, Connection con)
-        throws TorqueException
+    public static List<${dbObjectClassName}> doSelect(
+                Criteria criteria,
+                Connection connection)
+            throws TorqueException
     {
-        return ${peerClassName}.populateObjects(
-                ${peerClassName}.doSelectVillageRecords(criteria, con));
+        if (criteria.getSelectColumns().size() == 0)
+        {
+            ${peerClassName}.addSelectColumns(criteria);
+        }
+        setDbName(criteria);
+
+        return ${peerClassName}.doSelect(
+                criteria,
+                new $recordMapperClass(),
+                getTableMap(),
+                connection);
     }
-    
+
     /**
-     * Method to do selects
+     * Selects ${dbObjectClassName} objects from the database which have
+     * the same content as the passed object.
      *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static List<${dbObjectClassName}> doSelect($dbObjectClassName obj) throws TorqueException
+    public static List<${dbObjectClassName}> doSelect($dbObjectClassName obj)
+            throws TorqueException
     {
-        return ${peerClassName}.doSelect(${peerClassName}.buildSelectCriteria(obj));
+        return ${peerClassName}.doSelect(
+            ${peerClassName}.buildSelectCriteria(obj));
     }

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.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/doSelectJoin.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm Wed Oct 27 22:52:15 2010
@@ -34,7 +34,9 @@
 #set ( $joinedDbObjectPackage = $joinedTableElement.getAttribute("dbObjectPackage") )
 #set ( $joinedDbObject = "${joinedDbObjectPackage}.$joinedDbObjectClassName" )
 #set ( $peerClassName = $tableElement.getAttribute("peerClassName") )
+#set ( $recordMapperClass = $tableElement.getAttribute("recordMapperClass") )
 #set ( $joinedPeerClassName = $joinedTableElement.getAttribute("peerClassName") )
+#set ( $joinedPeerMapperName = $joinedTableElement.getAttribute("recordMapperClass") )
 #set ( $joinedPeerPackage = $joinedTableElement.getAttribute("peerPackage") )
 #set ( $joinedPeer = "${joinedPeerPackage}.$joinedPeerClassName" )
 #set ( $referenceElements = $foreignKeyElement.getChildren("reference") )
@@ -54,7 +56,25 @@
     protected static List<${dbObjectClassName}> ${peerJoinSelectMethod}(Criteria criteria)
         throws TorqueException
     {
-        return $peerClassName.${peerJoinSelectMethod}(criteria, null);
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    DATABASE_NAME,
+                    true);
+            List<${dbObjectClassName}> result
+                    = $peerClassName.${peerJoinSelectMethod}(criteria, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
     }
 
     /**
@@ -74,9 +94,11 @@
         setDbName(criteria);
 
         ${peerClassName}.addSelectColumns(criteria);
-        int offset = numColumns + 1;
         ${joinedPeer}.addSelectColumns(criteria);
 
+        CompositeMapper compositeMapper = new CompositeMapper();
+        compositeMapper.addMapper(new ${peerClassName}.${recordMapperClass}(), 0);
+        compositeMapper.addMapper(new ${joinedPeer}.$joinedPeerMapperName(), numColumns);
   #foreach ($referenceElement in $referenceElements)
     #set ( $joinedColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
     #set ( $joinedPeerColumnName = $joinedColumnElement.getAttribute("peerColumnName") )
@@ -88,41 +110,18 @@
 
         correctBooleans(criteria);
 
-        List<Record> rows;
-        if (conn == null)
-        {
-            rows = BasePeer.doSelectVillageRecords(criteria);
-        }
-        else
+        List<$dbObjectClassName> result = new ArrayList<$dbObjectClassName>();
+        List<List<Object>> rawResult = ${peerClassName}.doSelect(
+                criteria, compositeMapper, ${peerClassName}.getTableMap(), conn);
+        for (List<Object> rawResultRow : rawResult)
         {
-            rows = BasePeer.doSelectVillageRecords(criteria, conn);
-        }
-
-        List<$dbObjectClassName> results = new ArrayList<$dbObjectClassName>();
-
-        for (int i = 0; i < rows.size(); i++)
-        {
-            Record row = rows.get(i);
-
-  #if ($tableElement.getChild("inheritance-column"))
-            Class omClass = ${peerClassName}.getOMClass(row, 1);
-  #else
-            Class omClass = ${peerClassName}.getOMClass();
-  #end
-            $dbObjectClassName obj1 = $peerClassName
-                .row2Object(row, 1, omClass);
-  #if ($otherTableElement.getChild("inheritance-column"))
-            omClass = ${joinedPeer}.getOMClass(row, offset);
-  #else
-            omClass = ${joinedPeer}.getOMClass();
-  #end
-            $joinedDbObjectClassName obj2 = $joinedPeer
-                .row2Object(row, offset, omClass);
+            $dbObjectClassName obj1 = ($dbObjectClassName) rawResultRow.get(0);
+            $joinedDbObjectClassName obj2 = (${joinedDbObjectClassName}) rawResultRow.get(1);
 
             boolean newObject = true;
-            for (int j = 0; j < results.size(); j++)
+            for (int j = 0; j < result.size(); j++)
             {
-                $dbObjectClassName temp_obj1 = results.get(j);
+                $dbObjectClassName temp_obj1 = result.get(j);
                 $joinedDbObject temp_obj2 = temp_obj1.${getterForJoinedDbObject}();
                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
                 {
@@ -140,7 +139,7 @@
                 obj2.${adder}(obj1);
             }
   #end
-            results.add(obj1);
+            result.add(obj1);
         }
-        return results;
+        return result;
     }

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.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/doSelectJoinAllExcept.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm Wed Oct 27 22:52:15 2010
@@ -33,8 +33,9 @@
   #set ( $tableName = $tableElement.getAttribute("name") )
   #set ( $excludeTableElement = $foreignKeyElement.getChild("table") )
   #set ( $peerClassName = $tableElement.getAttribute("peerClassName") )
+  #set ( $tableField = $tableElement.getAttribute("field") )
   #set ( $peerPackage = $tableElement.getAttribute("peerPackage") )
-  #set ( $peer = "${peerPackage}.$peerClassName" )
+  #set ( $recordMapperClass = $tableElement.getAttribute("recordMapperClass") )
   #set ( $dbObjectClassName = $tableElement.getAttribute("dbObjectClassName") )
   #set ( $dbObjectPackage = $tableElement.getAttribute("dbObjectPackage") )
   #set ( $dbObject = "${dbObjectPackage}.$dbObjectClassName" )
@@ -52,7 +53,25 @@
     protected static List<${dbObjectClassName}> ${peerJoinAllExceptSelectMethod}(Criteria criteria)
         throws TorqueException
     {
-        return ${peerJoinAllExceptSelectMethod}(criteria, null);
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    DATABASE_NAME,
+                    true);
+            List<${dbObjectClassName}> result
+                    = $peerClassName.${peerJoinAllExceptSelectMethod}(criteria, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
     }
 
     /**
@@ -71,9 +90,10 @@
     {
         setDbName(criteria);
 
-        ${peer}.addSelectColumns(criteria);
-        int offset2 = numColumns + 1;
-  #set ( $index = 2 )
+        CompositeMapper compositeMapper = new CompositeMapper();
+        compositeMapper.addMapper(new ${peerClassName}.${recordMapperClass}(), 0);
+        ${peerClassName}.addSelectColumns(criteria);
+        int offset = numColumns;
   #foreach ($joinedForeignKeyElement in $foreignKeyElements)
     #if ($joinedForeignKeyElement != $foreignKeyElement)
       #set ( $joinedTableElement = $joinedForeignKeyElement.getChild("table"))
@@ -83,6 +103,7 @@
         #set ( $joinedPeerClassName = $joinedTableElement.getAttribute("peerClassName") )
         #set ( $joinedPeerPackage = $joinedTableElement.getAttribute("peerPackage") )
         #set ( $joinedPeer = "${joinedPeerPackage}.${joinedPeerClassName}" )
+        #set ( $joinedPeerMapperName = $joinedTableElement.getAttribute("recordMapperClass") )
         #set ( $referenceElements = $joinedForeignKeyElement.getChildren("reference") )
  
         ${joinedPeer}.addSelectColumns(criteria);
@@ -91,43 +112,23 @@
           #set ( $joinedColumnElement = $referenceElement.getChild("foreign-column").getChild("column"))
           #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") )
           #set ( $joinedPeerColumnName = $joinedColumnElement.getAttribute("peerColumnName") )
-        criteria.addJoin(${peer}.$peerColumnName, ${joinedPeer}.$joinedPeerColumnName);
-        #end
-        #if($index < $foreignKeyElements.size())
-          #set ( $new_index = $index + 1 )
-        int offset$new_index = offset$index + ${joinedPeer}.numColumns;
-          #set ( $index = $new_index )
+        criteria.addJoin(${peerClassName}.$peerColumnName, ${joinedPeer}.$joinedPeerColumnName);
         #end
+        compositeMapper.addMapper(new ${joinedPeer}.$joinedPeerMapperName(), offset);
+        offset = offset + ${joinedPeer}.numColumns;
       #end
     #end
   #end
 
         correctBooleans(criteria);
 
-        List<Record> rows;
-        if (conn == null)
-        {
-            rows = BasePeer.doSelectVillageRecords(criteria);
-        }
-        else
-        {
-            rows = BasePeer.doSelectVillageRecords(criteria,conn);
-        }
-
-        List<${dbObjectClassName}> results = new ArrayList<${dbObjectClassName}>();
-
-        for (int i = 0; i < rows.size(); i++)
+        List<$dbObjectClassName> result = new ArrayList<$dbObjectClassName>();
+        List<List<Object>> rawResult = ${peerClassName}.doSelect(
+                criteria, compositeMapper, ${peerClassName}.getTableMap(), conn);
+        for (List<Object> rawResultRow : rawResult)
         {
-            Record row = rows.get(i);
-
-  #if ($tableElement.getChild("inheritance-column"))
-            Class omClass = ${peer}.getOMClass(row, 1);
-  #else
-            Class omClass = ${peer}.getOMClass();
-  #end
-            $dbObject obj1 = $peer
-                .row2Object(row, 1, omClass);
-  #set ( $index = 1 )
+            $dbObjectClassName $tableField = ($dbObjectClassName) rawResultRow.get(0);
+  #set ( $index = 0 )
   #foreach ($joinedForeignKeyElement in $foreignKeyElements)
     #if ($joinedForeignKeyElement != $foreignKeyElement)
       #set ( $joinedTableElement = $joinedForeignKeyElement.getChild("table"))
@@ -147,28 +148,22 @@
         #set ( $getter = $localField.getAttribute("getter") )
         #set ( $index = $index + 1 )
 
-        #if ($joinedTableElement.getChild("inheritance-column"))
-            omClass = ${joinedPeer}.getOMClass(row, offset$index);
-        #else
-            omClass = ${joinedPeer}.getOMClass();
-        #end
-            $joinedDbObject obj$index = ${joinedPeer}
-                .row2Object( row, offset$index, omClass);
-         #if ($index == 2)
+            $joinedDbObject obj$index = (${joinedDbObject}) rawResultRow.get($index);
+         #if ($index == 1)
            #set ( $boolean = "boolean " )
          #else
            #set ( $boolean = "")
          #end
             ${boolean}newObject = true;
-            for (int j = 0; j < results.size(); j++)
+            for (int j = 0; j < result.size(); j++)
             {
-                $dbObject temp_obj1 = results.get(j);
-                $joinedDbObject temp_obj$index = temp_obj1.${getter}();
+                $dbObject temp_${tableField} = result.get(j);
+                $joinedDbObject temp_obj$index = temp_${tableField}.${getter}();
                 if (temp_obj${index}.getPrimaryKey().equals(obj${index}.getPrimaryKey()))
                 {
                     newObject = false;
                 #if ($objectIsCaching)
-                    temp_obj${index}.${adderInJoinedDbObject}(obj1);
+                    temp_obj${index}.${adderInJoinedDbObject}($tableField);
                 #end
                     break;
                 }
@@ -177,14 +172,14 @@
             if (newObject)
             {
                 obj${index}.${initializerInJoinedDbObject}();
-                obj${index}.${adderInJoinedDbObject}(obj1);
+                obj${index}.${adderInJoinedDbObject}($tableField);
             }
         #end
       #end
     #end
   #end
-            results.add(obj1);
+            result.add($tableField);
         }
-        return results;
+        return result;
     }
 #end

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.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/doUpdate.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm Wed Oct 27 22:52:15 2010
@@ -30,14 +30,31 @@
     /**
      * Method to do updates.
      *
-     * @param criteria object containing data that is used to create the UPDATE
-     *        statement.
+     * @param columnValues the values to update plus the primary key
+     *        identifying the row to update.
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static void doUpdate(Criteria criteria) throws TorqueException
+    public static int doUpdate(ColumnValues columnValues) throws TorqueException
     {
-         ${peerClassName}.doUpdate(criteria, (Connection) null);
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    DATABASE_NAME,
+                    true);
+            int result = ${peerClassName}.doUpdate(columnValues, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
     }
 
     /**
@@ -45,17 +62,20 @@
      * otherwise use the doUpdate(Criteria) method.  It will take care of
      * the connection details internally.
      *
-     * @param criteria object containing data that is used to create the UPDATE
-     *        statement.
-     * @param con the connection to use
+     * @param columnValues the values to update plus the primary key
+     *        identifying the row to update.
+     * @param con the connection to use, not null.
+     *
+     * @return the number of affected rows.
+     *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static void doUpdate(Criteria criteria, Connection con)
+    public static int doUpdate(ColumnValues columnValues, Connection con)
         throws TorqueException
     {
         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
-        ${peerClassName}.correctBooleans(criteria);
+        ${peerClassName}.correctBooleans(columnValues);
 
 #foreach ($columnElement in $torqueGen.getChildren("column"))
 
@@ -64,56 +84,58 @@
     
         selectCriteria.put(
                 ${peerClassName}.$peerColumnName,
-                criteria.remove(${peerClassName}.$peerColumnName));
+                columnValues.remove(${peerClassName}.$peerColumnName).getValue());
   #end
 #end
-
-        setDbName(criteria);
-
-        if (con == null)
-        {
-            BasePeer.doUpdate(selectCriteria, criteria);
-        }
-        else
-        {
-            BasePeer.doUpdate(selectCriteria, criteria, con);
-        }
+        return BasePeer.doUpdate(selectCriteria, columnValues, con);
     }
-    
+
     /**
+     * Updates an $dbObjectClassName in the database.
+     * The primary key is used to identify the object to update.
+     *
      * @param obj the data object to update in the database.
+     *
+     * @return the number of affected rows.
+     *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static void doUpdate($dbObjectClassName obj) throws TorqueException
+    public static int doUpdate($dbObjectClassName obj) throws TorqueException
     {
 #if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty())
         throw new TorqueException(
                 "doUpdate does not work for objects without primary key");
 #else
-        ${peerClassName}.doUpdate(${peerClassName}.buildCriteria(obj));
+        ColumnValues columnValues = ${peerClassName}.buildColumnValues(obj);
+        int result = ${peerClassName}.doUpdate(columnValues);
         obj.setModified(false);
+        return result;
 #end
     }
 
     /**
-     * Method to do update.  This method is to be used during a transaction,
-     * otherwise use the doUpdate($dbObjectClassName) method.  It will take
-     * care of the connection details internally.
+     * Updates a $dbObjectClassName in the database.
+     * The primary key is used to identify the object to update.
+     * This method is to be used during a transaction,
+     * otherwise the doUpdate($dbObjectClassName) method can be used.
      *
      * @param obj the data object to update in the database.
-     * @param con the connection to use
+     * @param con the connection to use, not null.
+     
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static void doUpdate($dbObjectClassName obj, Connection con)
+    public static int doUpdate($dbObjectClassName obj, Connection con)
         throws TorqueException
     {
   #if ($torqueGen.getChild("primary-keys").getChildren("column").isEmpty())
         throw new TorqueException(
                 "doUpdate does not work for objects without primary key");
   #else
-        ${peerClassName}.doUpdate(${peerClassName}.buildCriteria(obj), con);
+        ColumnValues columnValues = ${peerClassName}.buildColumnValues(obj);
+        int result = ${peerClassName}.doUpdate(columnValues, con);
         obj.setModified(false);
+        return result;
   #end
     }

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.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/getOMClass.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm Wed Oct 27 22:52:15 2010
@@ -27,62 +27,6 @@
 ## The options and the attributes of the current source element must be set
 ## as velocity variables.  
 ##
-#set ( $inheritanceBaseColumnElement = $torqueGen.getChild("inheritance-column") )
-#if ($inheritanceBaseColumnElement)
-  #set ( $columnElement = $inheritanceBaseColumnElement.getChild("column") )
-    /**
-     * The returned Class will contain objects of the default type or
-     * objects that inherit from the default.
-     *
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
-     */
-    public static Class getOMClass(Record record, int offset)
-        throws TorqueException
-    {
-        Class omClass;
-        try
-        {
-  #set ($inheritanceElements = $columnElement.getChildren("inheritance"))
-  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-  #set ( $villageMethod = $columnElement.getAttribute("villageMethod") )
-  #set ( $position = $columnElement.getAttribute("position") )
-  #set ( $primitive = ($columnElement.getAttribute("primitive") == "true") )
-  #if (!$inheritanceElements.isEmpty())
-            $fieldType classKey =
-                record.getValue(offset - 1 + $position)
-                .$villageMethod;
-    #set ($if = "if")
-    #foreach ($inheritanceElement in $inheritanceElements)
-      #set ( $classkeyConstant = $inheritanceElement.getAttribute("classkeyConstant") )
-      #set ( $classConstant = $inheritanceElement.getAttribute("classConstant") )
-      #if ($primitive)
-            $if (classKey == $classkeyConstant)
-      #else
-            $if (${classkeyConstant}.equals(classKey))
-      #end
-            {
-                omClass = ${peerClassName}.$classConstant;
-            }
-      #set ($if = "else if")
-    #end
-            else
-            {
-                omClass = ${peerClassName}.getOMClass();
-            }
-  #else
-            omClass = Class.forName(
-                record.getValue(offset - 1 + $position).asString());
-  #end
-        }
-        catch (Exception e)
-        {
-            throw new TorqueException(e);
-        }
-        return omClass;
-    }
-#end
-
     /**
      * The class that the Peer will make instances of.
      * If the BO is abstract then you must implement this method

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.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/imports.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm Wed Oct 27 22:52:15 2010
@@ -27,8 +27,20 @@
 ## The options and the attributes of the current source element must be set
 ## as velocity variables.  
 ##
+import java.sql.Blob;
+import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
@@ -42,6 +54,8 @@ import org.apache.torque.TorqueException
 import org.apache.torque.TorqueRuntimeException;
 import org.apache.torque.map.MapBuilder;
 import org.apache.torque.map.TableMap;
+import org.apache.torque.om.mapper.RecordMapper;
+import org.apache.torque.om.mapper.CompositeMapper;
 import org.apache.torque.om.DateKey;
 import org.apache.torque.om.NumberKey;
 import org.apache.torque.om.StringKey;
@@ -49,9 +63,8 @@ import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.Criteria;
-
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.QueryDataSet;
-import com.workingdogs.village.Record;
+import org.apache.torque.util.Transaction;
+import org.apache.torque.util.ColumnValues;
+import org.apache.torque.util.JdbcTypedValue;
 
 import ${mapBuilderPackage}.*;

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.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/recordmapper/createDbObjectInstanceFromInheritance.vm?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.vm (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.vm Wed Oct 27 22:52:15 2010
@@ -0,0 +1,80 @@
+## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $
+##
+## Creates the base peer's mapper class. 
+## 
+## This template expects the current source element to be 
+## a "inheritance-column" element from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The attributes of the current source element must be set
+## as velocity variables.  
+##
+#set ( $inheritanceBaseColumnElement = $torqueGen.getSourceElement() )
+#set ( $tableElement = $torqueGen.getParent() )
+#set ( $tableField = $tableElement.getAttribute("field") )
+#set ( $dbObjectClassName = $tableElement.getAttribute("dbObjectClassName") )
+#set ( $columnElement = $inheritanceBaseColumnElement.getChild("column") )
+#set ( $inheritanceElements = $columnElement.getChildren("inheritance"))
+#set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+#set ( $position = $columnElement.getAttribute("position") )
+#set ( $getter = $columnElement.getAttribute("getter") )
+#set ( $primitive = ($columnElement.getAttribute("primitive") == "true") )
+            $columnFieldType classKey =
+                $getter(resultSet, offset + $position);
+            $dbObjectClassName $tableField;
+#if (!$inheritanceElements.isEmpty())
+  #set ($if = "if")
+  #foreach ($inheritanceElement in $inheritanceElements)
+    #set ( $inheritanceClasskeyConstant = $inheritanceElement.getAttribute("classkeyConstant") )
+    #set ( $inheritanceClassName = $inheritanceElement.getAttribute("className") )
+    #if ($primitive)
+            $if (classKey == $inheritanceClasskeyConstant)
+    #else
+            $if (${inheritanceClasskeyConstant}.equals(classKey))
+    #end
+            {
+                $tableField = new ${inheritanceClassName}();
+            }
+    #set ($if = "else if")
+  #end
+            else
+            {
+                $tableField = new $dbObjectClassName();
+            }
+#else
+            try
+            {
+                Class<?> omClass = Class.forName(classKey.toString());
+                $tableField = ($dbObjectClassName) omClass.newInstance();
+            }
+            catch (InstantiationException e)
+            {
+                throw new TorqueException(e);
+            }
+            catch (IllegalAccessException e)
+            {
+                throw new TorqueException(e);
+            }
+            catch (ClassNotFoundException e)
+            {
+                throw new TorqueException(e);
+            }
+#end

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.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/recordmapper/dbObjectFieldGetter.vm?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.vm (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.vm Wed Oct 27 22:52:15 2010
@@ -0,0 +1,80 @@
+## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $
+##
+## Creates the setter methods in the base peer's mapper class. 
+## 
+## This template expects the current source element to be a "column" element 
+## from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The attributes of the current source element must be set
+## as velocity variables.  
+##
+#set ($tableElement = $torqueGen.getParent())
+#set ($dbObjectClassName = $tableElement.getAttribute("dbObjectClassName"))
+        /**
+         * Reads the value of the <code>columnIndex</code>'th column
+         * in the <code>resultSet</code> so that it can be used to set
+         * the field $field in $dbObjectClassName.
+         *
+         * @param dbObject the database object to fill, not null.
+         * @param resultSet the ResultSet to read from, not null.
+         * @param columnIndex the index in the resultSet which should be read.
+         *
+         * @throws SQLException if a problem occurs when reading
+         *         from the resultSet.
+         */
+        protected $fieldType ${getter}(
+                    ResultSet resultSet,
+                    int columnIndex)
+                throws TorqueException
+        {
+            try
+            {
+#if ($schemaType.toString() == "BOOLEANCHAR")
+                String stringValue = resultSet.getString(columnIndex);
+                if ("Y".equals(stringValue))
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+#elseif ($schemaType.toString() == "BOOLEANINT")
+                int intValue = resultSet.getInt(columnIndex);
+                if (1 == intValue)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+#else
+                return resultSet.${resultSetGetter}(columnIndex);
+#end
+            }
+            catch (SQLException e)
+            {
+                throw new TorqueException(e);
+            }
+        }
+

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.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/recordmapper/recordMapper.vm?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.vm (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.vm Wed Oct 27 22:52:15 2010
@@ -0,0 +1,67 @@
+## 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: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer $
+##
+## Creates the base peer's mapper class. 
+## 
+## This template expects the current source element to be a "table" element 
+## from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The attributes of the current source element must be set
+## as velocity variables.  
+##
+    public static class $recordMapperClass implements RecordMapper<$dbObjectClassName>
+    {
+        /**
+         * Constructs the object from the current row in the resultSet.
+         *
+         * @param resultSet the resultSet to operate on, already pointing
+         *        to the correct row. Not null.
+         * @param a possible offset in the rows to be considered
+         *        (if previous rows contain other objects).
+         *
+         * @return the mapped object, not null.
+         *
+         * @throws TorqueException when reading fields from the RecordSet fails.
+         */
+        public $dbObjectClassName processRow(ResultSet resultSet, int offset)
+                throws TorqueException
+        {
+#set ( $inheritanceBaseColumnElement = $torqueGen.getChild("inheritance-column") )
+#if ($inheritanceBaseColumnElement)
+$torqueGen.mergepoint("createDbObjectInstanceFromInheritance")
+#else
+$torqueGen.mergepoint("createDbObjectInstance")
+#end
+#set ( $n = 1 )
+#foreach ($columnElement in $torqueGen.getChildren("column"))
+  #set ( $setter = $columnElement.getAttribute("setter") )
+  #set ( $getter = $columnElement.getAttribute("getter") )
+           $field.${setter}(
+                   ${getter}(resultSet, offset + $n));
+  #set ( $n = $n + 1 )
+#end
+           ${field}.setNew(false);
+           ${field}.setModified(false);
+           return $field;
+        }
+
+$torqueGen.mergepoint("dbObjectFieldGetters")
+    }

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.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/resultSet2Objects.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.vm Wed Oct 27 22:52:15 2010
@@ -32,39 +32,27 @@
      * resultset MUST return columns in the right order.  You can use
      * getFieldNames() in BaseObject to get the correct sequence.
      *
-     * @param results the ResultSet
+     * @param resultSet the ResultSet
      * @return the list of objects
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static List<${dbObjectClassName}> resultSet2Objects(java.sql.ResultSet results)
+    public static List<${dbObjectClassName}> resultSet2Objects(java.sql.ResultSet resultSet)
             throws TorqueException
     {
         try
         {
-            QueryDataSet qds = null;
-            List<Record> rows = null;
-            try
+            $recordMapperClass mapper = new ${recordMapperClass}();
+            List<${dbObjectClassName}> result
+                    = new ArrayList<${dbObjectClassName}>();
+            while (resultSet.next())
             {
-                qds = new QueryDataSet(results);
-                rows = ${peerClassName}.getSelectResults(qds);
+                result.add(mapper.processRow(resultSet, 0));
             }
-            finally
-            {
-                if (qds != null)
-                {
-                    qds.close();
-                }
-            }
-
-            return ${peerClassName}.populateObjects(rows);
+            return result;
         }
         catch (SQLException e)
         {
             throw new TorqueException(e);
         }
-        catch (DataSetException e)
-        {
-            throw new TorqueException(e);
-        }
     }



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