db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r910600 [25/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/m...
Date Tue, 16 Feb 2010 17:16:02 GMT
Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/classJavadoc.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/classJavadoc.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/classJavadoc.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/classJavadoc.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,39 @@
+## 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 class javadoc for a base DB object.
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+/**
+#if ($description)
+ * $description
+ *
+#end
+#if ($torqueGf.booleanOption("torque.om.addTimeStamp"))
+ * This class was autogenerated by Torque on:
+ *
+ * [${torqueGf.now()}]
+ *
+#end
+ * You should not use this class directly.  It should not even be
+ * extended; all references should be to $dbObjectClassName
+ */

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,240 @@
+## 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 copy methods for a database base object.
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+    /**
+     * Makes a copy of this object.
+     * It creates a new object filling in the simple attributes.
+  #if ($complexObjectModel)
+     * It then fills all the association collections and sets the
+     * related objects to isNew=true.
+  #end
+     */
+    public $dbObjectClassName copy() throws TorqueException
+    {
+#if ($complexObjectModel)
+        return copy(true);
+#else
+        return copyInto(new ${table.JavaName}());
+#end
+    }
+
+#if ($complexObjectModel)
+    /**
+     * Makes a copy of this object using a connection.
+     * It creates a new object filling in the simple attributes.
+     * It then fills all the association collections and sets the
+     * related objects to isNew=true.
+     *
+     * @param con the database connection to read associated objects.
+     */
+    public $dbObjectClassName copy(Connection con) throws TorqueException
+    {
+        return copy(true, con);
+    }
+
+    /**
+     * Makes a copy of this object.
+     * It creates a new object filling in the simple attributes.
+     * If the parameter deepcopy is true, it then fills all the
+     * association collections and sets the related objects to
+     * isNew=true.
+     *
+     * @param deepcopy whether to copy the associated objects.
+     */
+    public $dbObjectClassName copy(boolean deepcopy) throws TorqueException
+    {
+        return copyInto(new ${dbObjectClassName}(), deepcopy);
+    }
+
+    /**
+     * Makes a copy of this object using connection.
+     * It creates a new object filling in the simple attributes.
+     * If the parameter deepcopy is true, it then fills all the
+     * association collections and sets the related objects to
+     * isNew=true.
+     *
+     * @param deepcopy whether to copy the associated objects.
+     * @param con the database connection to read associated objects.
+     */
+    public $dbObjectClassName copy(boolean deepcopy, Connection con) throws TorqueException
+    {
+        return copyInto(new ${dbObjectClassName}(), deepcopy, con);
+    }
+#end
+  
+#if ($complexObjectModel)
+    /**
+     * Fills the copyObj with the contents of this object.
+     * The associated objects are also copied and treated as new objects.
+     *
+     * @param copyObj the object to fill.
+     */
+    protected $dbObjectClassName copyInto($dbObjectClassName copyObj) throws TorqueException
+    {
+        return copyInto(copyObj, true);
+    }
+
+    /**
+     * Fills the copyObj with the contents of this object using connection.
+     * The associated objects are also copied and treated as new objects.
+     *
+     * @param copyObj the object to fill.
+     * @param con the database connection to read associated objects.
+     */
+    protected $dbObjectClassName copyInto($dbObjectClassName copyObj, Connection con) throws TorqueException
+    {
+        return copyInto(copyObj, true, con);
+    }
+#end
+  
+    /**
+     * Fills the copyObj with the contents of this object.
+#if ($complexObjectModel)
+     * If deepcopy is true, The associated objects are also copied
+     * and treated as new objects.
+     *
+#end
+     * @param copyObj the object to fill.
+#if ($complexObjectModel)
+     * @param deepcopy whether the associated objects should be copied.
+#end
+     */
+#if ($complexObjectModel)
+    protected $dbObjectClassName copyInto($dbObjectClassName copyObj, boolean deepcopy) throws TorqueException
+#else
+    protected $dbObjectClassName copyInto($dbObjectClassName copyObj) throws TorqueException
+#end
+    {
+#set ( $columnElements = $torqueGf.getChildren("column") )
+#foreach ($columnElement in $columnElements)
+  #set ( $setter = $columnElement.getAttribute("setter") )
+  #set ( $field = $columnElement.getAttribute("field") )
+  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $defaultValue = $columnElement.getAttribute("defaultValue") )
+  #if($columnElement.getAttribute("primaryKey") != "true")
+        copyObj.${setter}($field);
+  #else
+    #if($columnElement.getAttribute("primitive") == "true")
+        copyObj.${setter}($defaultValue);
+    #else
+        copyObj.${setter}((${fieldType}) $defaultValue);
+    #end
+  #end
+#end
+
+#if ($complexObjectModel)
+  #set ($foreignKeyElements = $torqueGf.getChild("referencing-foreign-keys").getChildren("foreign-key"))
+        if (deepcopy)
+        {
+  #foreach ($foreignKeyElement in $foreignKeyElements)
+    #set ( $foreignTableElement = $foreignKeyElement.getParent())
+    #set ( $foreignTableName = $foreignTableElement.getAttribute("name"))
+    #set ( $foreignFieldElement = $foreignKeyElement.getChild("foreign-field"))
+    #set ( $field = $foreignFieldElement.getAttribute("field"))
+    #set ( $fieldType = $foreignFieldElement.getAttribute("fieldType"))
+    #set ( $fieldContainedType = $foreignFieldElement.getAttribute("fieldContainedType"))
+    #set ( $getter = $foreignFieldElement.getAttribute("getter"))
+    #set ( $adder = $foreignFieldElement.getAttribute("adder"))
+    #if ($foreignTableName != $name)
+      #if ($objectIsCaching)
+          ## field can be null if the generator property
+          ## torque.silentDbFetch is set to false
+            if ($field != null)
+            {
+                for (int i = 0; i < ${field}.size(); i++)
+                {
+                    ${fieldContainedType} obj = #if($java5 != "true")($fieldContainedType)#end ${field}.get(i);
+                    copyObj.${adder}(obj.copy());
+                }
+            }
+            else
+            {
+                copyObj.${field} = null;
+            }
+      #end
+    #end
+  #end
+        }
+#end
+        return copyObj;
+    }
+        
+    
+#if ($complexObjectModel)
+    /**
+     * Fills the copyObj with the contents of this object using connection.
+     * If deepcopy is true, The associated objects are also copied
+     * and treated as new objects.
+     *
+     * @param copyObj the object to fill.
+     * @param deepcopy whether the associated objects should be copied.
+     * @param con the database connection to read associated objects.
+     */
+    protected $dbObjectClassName copyInto($dbObjectClassName copyObj, boolean deepcopy, Connection con) throws TorqueException
+    {
+  #set ( $columnElements = $torqueGf.getChildren("column") )
+  #foreach ($columnElement in $columnElements)
+    #set ( $setter = $columnElement.getAttribute("setter") )
+    #set ( $field = $columnElement.getAttribute("field") )
+    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+    #set ( $defaultValue = $columnElement.getAttribute("defaultValue") )
+    #if($columnElement.getAttribute("primaryKey") != "true")
+        copyObj.${setter}($field);
+    #else
+      #if($columnElement.getAttribute("primitive") == "true")
+        copyObj.${setter}($defaultValue);
+      #else
+        copyObj.${setter}((${fieldType}) $defaultValue);
+      #end
+    #end
+  #end
+
+  #set ($foreignKeyElements = $torqueGf.getChild("referencing-foreign-keys").getChildren("foreign-key"))
+        if (deepcopy)
+        {
+  #foreach ($foreignKeyElement in $foreignKeyElements)
+    #set ( $foreignTableElement = $foreignKeyElement.getParent())
+    #set ( $foreignTableName = $foreignTableElement.getAttribute("name"))
+    #set ( $foreignFieldElement = $foreignKeyElement.getChild("foreign-field"))
+    #set ( $field = $foreignFieldElement.getAttribute("field"))
+    #set ( $fieldType = $foreignFieldElement.getAttribute("fieldType"))
+    #set ( $fieldContainedType = $foreignFieldElement.getAttribute("fieldContainedType"))
+    #set ( $getter = $foreignFieldElement.getAttribute("getter"))
+    #set ( $adder = $foreignFieldElement.getAttribute("adder"))
+    #if ($foreignTableName != $name)
+      #if ($objectIsCaching)
+            $getter(con);
+            for (int i = 0; i < ${field}.size(); i++)
+            {
+                ${fieldContainedType} obj = #if($java5 != "true")($fieldContainedType) #end${field}.get(i);
+                copyObj.${adder}(obj.copy());
+            }
+      #end
+    #end
+  #end
+        }
+        return copyObj;
+    }
+#end

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getByNameMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getByNameMethods.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getByNameMethods.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getByNameMethods.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,306 @@
+## 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 getters/setters by name.
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+#set ( $java5 = $torqueGf.booleanOption("torque.om.java5") )
+#set ( $columnElements = $torqueGf.getChildren("column") )
+#set ( $peerName = "${peerPackage}.${peerClassName}" )
+
+    private static final List#if($java5)<String>#end FIELD_NAMES;
+
+    static
+    {
+        List#if($java5)<String>#end fieldNames
+                = new ArrayList#if($enableJava5Features)<String>#end();
+#foreach ($columnElement in $columnElements)
+        fieldNames.add("${columnElement.getAttribute("javaName")}");
+#end
+        FIELD_NAMES = Collections.unmodifiableList(fieldNames);
+    }
+
+    /**
+     * Generate a list of field names.
+     *
+     * @return a list of field names
+     */
+    public static List#if($java5)<String>#end getFieldNames()
+    {
+        return FIELD_NAMES;
+    }
+
+    /**
+     * Retrieves a field from the object by field (Java) name passed in as a String.
+     *
+     * @param name field name
+     * @return value
+     */
+    public Object getByName(String name)
+    {
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $javaName = ${columnElement.getAttribute("javaName")} )
+  #set ( $getter = ${columnElement.getAttribute("getter")} )
+        if (name.equals("$javaName"))
+        {
+  #if ($fieldType == "int")
+            return new Integer(${getter}());
+  #elseif ($fieldType == "long")
+            return new Long(${getter}());
+  #elseif ($fieldType == "float")
+            return new Float(${getter}());
+  #elseif ($fieldType == "double")
+            return new Double(${getter}());
+  #elseif ($fieldType == "boolean")
+            return new Boolean(${getter}());
+  #elseif ($fieldType == "short")
+            return new Short(${getter}());
+  #elseif ($fieldType == "byte")
+            return new Byte(${getter}());
+  #elseif ($fieldType == "char")
+            return new Character(${getter}());
+  #else
+            return ${getter}();
+  #end
+        }
+#end
+        return null;
+    }
+
+    /**
+     * Set a field in the object by field (Java) name.
+     *
+     * @param name field name
+     * @param value field value
+     * @return True if value was set, false if not (invalid name / protected field).
+     * @throws IllegalArgumentException if object type of value does not match field object type.
+     * @throws TorqueException If a problem occurs with the set[Field] method.
+     */
+    public boolean setByName(String name, Object value )
+        throws TorqueException, IllegalArgumentException
+    {
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $javaName = ${columnElement.getAttribute("javaName")} )
+  #set ( $setter = ${columnElement.getAttribute("setter")} )
+  #set ( $primitive = ${columnElement.getAttribute("primitive")} )
+        if (name.equals("${javaName}"))
+        {
+  #if ( ${primitive} == "true" )
+    #if ($fieldType == "int")
+            if (value == null || ! (Integer.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
+            }
+            ${setter}(((Integer) value).intValue());
+    #elseif ($fieldType == "long")
+            if (value == null || ! (Long.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Long object.");
+            }
+            ${setter}(((Long) value).longValue());
+    #elseif ($fieldType == "float")
+            if (value == null || ! (Float.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Float object.");
+            }
+            ${setter}(((Float) value).floatValue());
+    #elseif ($fieldType == "double")
+            if (value == null || ! (Double.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Double object.");
+            }
+            ${setter}(((Double) value).doubleValue());
+    #elseif ($fieldType == "boolean")
+            if (value == null || ! (Boolean.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Boolean object.");
+            }
+            ${setter}(((Boolean)value).booleanValue());
+    #elseif ($fieldType == "short")
+            if (value == null || ! (Short.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Short object.");
+            }
+            ${setter}(((Short)value).shortValue());
+    #elseif ($fieldType == "byte")
+            if (value == null || ! (Byte.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Byte object.");
+            }
+            ${setter}(((Byte) value).byteValue());
+    #elseif ($fieldType == "char")
+            if (value == null || ! (Character.class.isInstance(value)))
+            {
+                throw new IllegalArgumentException("setByName: value parameter was null or not a Character object.");
+            }
+            ${setter}(((Character) value).charValue());
+    #end
+  #else
+    #if ( ${fieldType} )
+            // Object fields can be null
+            if (value != null && ! ${fieldType}.class.isInstance(value))
+            {
+                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
+            }
+            ${setter}(($fieldType) value);
+    #else
+            // Hmm, using column type that can't be mapped to a Java object class, make this obvious.
+            throw IllegalStateException("Can't determine Java Object type for column, ${javaName}!");
+    #end
+  #end
+            return true;
+        }
+#end
+        return false;
+    }
+
+    /**
+     * Retrieves a field from the object by name passed in
+     * as a String.  The String must be one of the static
+     * Strings defined in this Class' Peer.
+     *
+     * @param name peer name
+     * @return value
+     */
+    public Object getByPeerName(String name)
+    {
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $getter = ${columnElement.getAttribute("getter")} )
+  #set ( $peerColumnName = ${columnElement.getAttribute("peerColumnName")} )
+        if (name.equals(${peerName}.${peerColumnName}))
+        {
+  #if ($fieldType == "int")
+            return new Integer(${getter}());
+  #elseif ($fieldType == "long")
+            return new Long(${getter}());
+  #elseif ($fieldType == "float")
+            return new Float(${getter}());
+  #elseif ($fieldType == "double")
+            return new Double(${getter}());
+  #elseif ($fieldType == "boolean")
+            return new Boolean(${getter}());
+  #elseif ($fieldType == "short")
+            return new Short(${getter}());
+  #elseif ($fieldType == "byte")
+            return new Byte(${getter}());
+  #elseif ($fieldType == "char")
+            return new Character(${getter}());
+  #else
+            return ${getter}();
+  #end
+        }
+#end
+        return null;
+    }
+
+    /**
+     * Set field values by Peer Field Name
+     *
+     * @param name field name
+     * @param value field value
+     * @return True if value was set, false if not (invalid name / protected field).
+     * @throws IllegalArgumentException if object type of value does not match field object type.
+     * @throws TorqueException If a problem occurs with the set[Field] method.
+     */
+    public boolean setByPeerName(String name, Object value)
+        throws TorqueException, IllegalArgumentException
+    {
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $javaName = ${columnElement.getAttribute("javaName")} )
+  #set ( $peerColumnName = ${columnElement.getAttribute("peerColumnName")} )
+        if (${peerName}.${peerColumnName}.equals(name))
+        {
+            return setByName("${javaName}", value);
+        }
+#end
+        return false;
+    }
+
+    /**
+     * Retrieves a field from the object by Position as specified
+     * in the xml schema.  Zero-based.
+     *
+     * @param pos position in xml schema
+     * @return value
+     */
+    public Object getByPosition(int pos)
+    {
+#set ($i = 0)
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $getter = ${columnElement.getAttribute("getter")} )
+        if (pos == $i)
+        {
+  #if ($fieldType == "int")
+            return new Integer(${getter}());
+  #elseif ($fieldType == "long")
+            return new Long(${getter}());
+  #elseif ($fieldType == "float")
+            return new Float(${getter}());
+  #elseif ($fieldType == "double")
+            return new Double(${getter}());
+  #elseif ($fieldType == "boolean")
+            return new Boolean(${getter}());
+  #elseif ($fieldType == "short")
+            return new Short(${getter}());
+  #elseif ($fieldType == "byte")
+            return new Byte(${getter}());
+  #elseif ($fieldType == "char")
+            return new Character(${getter}());
+  #else
+            return ${getter}();
+  #end
+        }
+  #set ($i = $i + 1)
+#end
+        return null;
+    }
+
+    /**
+     * Set field values by its position (zero based) in the XML schema.
+     *
+     * @param position The field position
+     * @param value field value
+     * @return True if value was set, false if not (invalid position / protected field).
+     * @throws IllegalArgumentException if object type of value does not match field object type.
+     * @throws TorqueException If a problem occurs with the set[Field] method.
+     */
+    public boolean setByPosition(int position, Object value)
+        throws TorqueException, IllegalArgumentException
+    {
+#set ($i = 0)
+#foreach ($columnElement in $columnElements)
+  #set ( $fieldType = ${columnElement.getAttribute("fieldType")} )
+  #set ( $javaName = ${columnElement.getAttribute("javaName")} )
+  #set ( $setter = ${columnElement.getAttribute("setter")} )
+        if (position == $i)
+        {
+            return setByName("${javaName}", value);
+        }
+  #set ( $i = $i + 1)
+#end
+        return false;
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencedObject.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,168 @@
+## 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 creates the getter method in the object for the "local" part
+## of a foreign key. The object in the field represents the "foreign" part
+## of the foreign key.  
+## The template expects as input a "local-field" element inside a 
+## "foreign-key" element from the torque schema, which was generated 
+## by the OMTransformer.  
+##
+#set ( $silentDbFetch = $torqueGf.booleanOption("torque.om.silentDbFetch") )
+#set ( $foreignKeyElement = $torqueGf.getParent() )
+#set ( $foreignTableElement = $foreignKeyElement.getChild("table") )
+#set ( $foreignTablePeerClass = "${foreignTableElement.getAttribute('peerPackage')}.${foreignTableElement.getAttribute('peerClassName')}" )
+#set ( $foreignTableManagerClass = "${foreignTableElement.getAttribute('managerPackage')}.${foreignTableElement.getAttribute('managerClassName')}" )
+#set ( $and = " && " )
+#set ( $conditional = "" )
+#set ( $arglist = "" )
+#set ( $argsize = 0 )
+#set ( $referenceElements = $foreignKeyElement.getChildren("reference") )
+#foreach ($referenceElement in $referenceElements)
+  #set ( $localColumnElement = $referenceElement.getChild("local-column").getChild("column"))
+  #set ( $localColumnField = ($localColumnElement.getAttribute("field")) )
+  #set ( $localColumnFieldType = ($localColumnElement.getAttribute("fieldType")) )
+  #if ($localColumnFieldType == "short" || $localColumnFieldType == "int" || $localColumnFieldType == "long" || $localColumnFieldType == "byte" || $localColumnFieldType == "float" || $localColumnFieldType == "double")
+    #set ( $conditional = "$conditional${and}this.${localColumnField} != 0" )
+  #elseif ($localColumnFieldType == "char")
+    #set ( $conditional = "$conditional${and}this.${localColumnField} != '\0'" )
+  #else
+    #set ( $conditional = "$conditional${and}!org.apache.commons.lang.ObjectUtils.equals(this.${localColumnField}, null)" )
+  #end
+  #if ($arglist != "" )
+    #if ($torqueGf.booleanOption("torque.om.useManagers"))
+      #set ( $arglist = "${arglist}, SimpleKey.keyFor(this.$localColumnField)" )
+    #else
+      #set ( $arglist = "${arglist}, this.$localColumnField" )
+    #end
+  #else
+    #if ($torqueGf.booleanOption("torque.om.useManagers"))
+      #set ( $arglist = "SimpleKey.keyFor(this.$localColumnField)" )
+    #else
+      #set ( $arglist = "this.$localColumnField" )
+    #end
+  #end
+  #set ( $argsize = $argsize + 1 )
+#end
+    /**
+     * Returns the associated $fieldType object.
+#if ($silentDbFetch)
+     * If it was not retrieved before, the object is retrieved from
+     * the database
+#end
+     *
+     * @return the associated $fieldType object
+#if ($silentDbFetch)
+     * @throws TorqueException when reading from the database fails.
+#end
+     */
+    public $fieldType ${getter}()
+#if ($silentDbFetch)
+        throws TorqueException
+#end
+    {
+#if ($silentDbFetch)
+        if ($field == null$conditional)
+        {
+  #if ($argsize > 1)
+    #if ($torqueGf.booleanOption("torque.om.useManagers"))
+            SimpleKey[] keys = { $arglist };
+            $field = ${foreignTableManagerClass}.getInstance(new ComboKey(keys));
+    #else
+            $field = ${foreignTablePeerClass}.retrieveByPK($arglist);
+    #end
+  #else
+    #if ($torqueGf.booleanOption("torque.om.useManagers"))
+            $field = ${foreignTableManagerClass}.getInstance($arglist);
+    #else
+            $field = ${foreignTablePeerClass}.retrieveByPK(SimpleKey.keyFor($arglist));
+    #end
+  #end
+##            /* The following can be used to
+##               guarantee the related object contains a reference
+##               to this object, but this level of coupling
+##               may be undesirable in many circumstances.
+##               As it can lead to a db query with many results that may
+##               never be used.
+##  #set ( $foreignFieldElement = $foreignKeyElement.getChild("foreign-field") )
+##  #set ( $foreignFieldAdder = $foreignFieldElement.getAttribute("adder") )
+##               $field.$foreignFieldAdder(this);
+##            */
+        }
+#end
+        return $field;
+    }
+
+    /**
+     * Return the associated $fieldType object
+     * If it was not retrieved before, the object is retrieved from
+     * the database using the passed connection
+     *
+     * @param connection the connection used to retrieve the associated object
+     *        from the database, if it was not retrieved before
+     * @return the associated $fieldType object
+     * @throws TorqueException
+     */
+    public $fieldType ${getter}(Connection connection)
+        throws TorqueException
+    {
+        if ($field == null$conditional)
+        {
+      #if ($argsize > 1)
+        #if ($torqueGf.booleanOption("torque.om.useManagers"))
+            SimpleKey[] keys = { $arglist };
+            ComboKey comboid = new ComboKey(keys);
+
+            $field = ${foreignTableManagerClass}.getCachedInstance(comboid);
+            if ($field == null)
+            {
+                $field = ${foreignTablePeerClass}.retrieveByPK(comboid, connection);
+                ${foreignTableManagerClass}.putInstance($field);
+            }
+        #else
+            $field = ${foreignTablePeerClass}.retrieveByPK($arglist, connection);
+        #end
+      #else
+        #if ($torqueGf.booleanOption("torque.om.useManagers"))
+            $field = ${foreignTableManagerClass}.getCachedInstance($arglist);
+            if ($field == null)
+            {
+                $field = ${foreignTablePeerClass}.retrieveByPK($arglist, connection);
+                ${foreignTableManagerClass}.putInstance($field);
+            }
+        #else
+            $field = ${foreignTablePeerClass}.retrieveByPK(SimpleKey.keyFor($arglist), connection);
+        #end
+      #end
+##            /* The following can be used to
+##               guarantee the related object contains a reference
+##               to this object, but this level of coupling
+##               may be undesirable in many circumstances.
+##               As it can lead to a db query with many results that may
+##               never be used.
+##  #set ( $foreignFieldElement = $foreignKeyElement.getChild("foreign-field") )
+##  #set ( $foreignFieldAdder = $foreignFieldElement.getAttribute("adder") )
+##               $field.$foreignFieldAdder(this);
+##            */
+        }
+        return $field;
+    }
+

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,245 @@
+## 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 creates the getter method in the object for the "foreign" part
+## of a foreign key. The objects in the field represent the "local" part
+## of the foreign key.  
+## The template expects as input a "foreign-field" element inside a 
+## "referencing-foreign-keys/foreign-key" element
+##
+#set ( $silentDbFetch = $torqueGf.booleanOption("torque.om.silentDbFetch") )
+#set ( $objectIsCaching = $torqueGf.booleanOption("torque.om.objectIsCaching") )
+#set ( $foreignKeyElement = $torqueGf.getParent() )
+#set ( $thisObjectClassName = $foreignKeyElement.getChild("table").getAttribute("baseDbObjectClassName") )
+#set ( $otherTable = $foreignKeyElement.getParent() )
+#set ( $otherTablePeerClass = $otherTable.getAttribute("peerClassName") )
+#set ( $otherTablePeerPackage = $otherTable.getAttribute("peerPackage") )
+#set ( $otherTablePeerName = "${otherTablePeerPackage}.${otherTablePeerClass}" )
+#set ( $referenceElements = $foreignKeyElement.getChildren("reference") )
+#if ( $objectIsCaching )
+    /**
+     * The criteria used to select the current contents of $field
+     */
+    private Criteria $criteriaCacheField = null;
+
+#end
+    /**
+#if ( $objectIsCaching)
+  #if (!$silentDbFetch)
+     * Returns the Collection.
+  #else
+     * If this collection has already been initialized, returns
+     * the collection. Otherwise returns the results of
+     * ${getter}(new Criteria())
+  #end
+#else
+     * A wrapper for ${getter}(new Criteria())
+#end
+     *
+     * @return the collection of associated objects
+#if ($silentDbFetch)
+     * @throws TorqueException
+#end
+     */
+    public $fieldType ${getter}()
+#if ($silentDbFetch)
+        throws TorqueException
+#end
+    {
+#if ($objectIsCaching)
+  #if (!$silentDbFetch)
+        if (isNew())
+        {
+            ${initializer}();
+        }
+  #else
+        if ($field == null)
+        {
+            $field = ${getter}(new Criteria(10));
+        }
+  #end
+        return $field;
+#else
+        return ${getter}(new Criteria(10));
+#end
+    }
+
+    /**
+#if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName has previously
+#else
+     * If this $thisObjectClassName has previously
+#end
+     * been saved, it will retrieve related ${field} from storage.
+     * If this $thisObjectClassName is new, it will return
+     * an empty collection or the current collection, the criteria
+     * is ignored on a new object.
+     *
+     * @throws TorqueException
+     */
+    public $fieldType ${getter}(Criteria criteria) throws TorqueException
+    {
+#if ($objectIsCaching)
+        if ($field == null)
+        {
+            if (isNew())
+            {
+               ${initializer}();
+            }
+            else
+            {
+  #foreach ($referenceElement in $referenceElements)
+    #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+    #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+    #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+  #end
+                $field = ${otherTablePeerName}.doSelect(criteria);
+            }
+        }
+        else
+        {
+            // criteria has no effect for a new object
+            if (!isNew())
+            {
+                // the following code is to determine if a new query is
+                // called for.  If the criteria is the same as the last
+                // one, just return the collection.
+#end
+#foreach ($referenceElement in $referenceElements)
+  #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+  #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+  #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+  #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+#end
+#if ($objectIsCaching)
+                if (!${criteriaCacheField}.equals(criteria))
+                {
+                    $field = ${otherTablePeerName}.doSelect(criteria);
+                }
+            }
+        }
+        $criteriaCacheField = criteria;
+
+        return $field;
+#else
+        return ${otherTablePeerName}.doSelect(criteria);
+#end
+    }
+
+    /**
+#if ($objectIsCaching)
+     * If this collection has already been initialized, returns
+     * the collection. Otherwise returns the results of
+     * ${getter}(new Criteria(),Connection)
+#else
+     * A wrapper for ${getter}(new Criteria(),Connection)
+#end
+     * This method takes in the Connection also as input so that
+     * referenced objects can also be obtained using a Connection
+     * that is taken as input
+     */
+    public $fieldType ${getter}(Connection con) throws TorqueException
+    {
+#if ($objectIsCaching)
+        if ($field == null)
+        {
+            $field = ${getter}(new Criteria(10), con);
+        }
+        return $field;
+#else
+        return ${getter}(new Criteria(10), con);
+#end
+    }
+
+    /**
+#if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName has previously
+#else
+     * If this $thisObjectClassName has previously
+#end
+     * been saved, it will retrieve the related $fieldContainedType Objects 
+     * from storage.
+     * If this $thisObjectClassName is new, it will return
+     * an empty collection or the current collection, the criteria
+     * is ignored on a new object.
+     * This method takes in the Connection also as input so that
+     * referenced objects can also be obtained using a Connection
+     * that is taken as input
+     */
+    public $fieldType ${getter}(Criteria criteria, Connection con)
+            throws TorqueException
+    {
+#if ($objectIsCaching)
+        if ($field == null)
+        {
+            if (isNew())
+            {
+               $initializer();
+            }
+            else
+            {
+  #foreach ($referenceElement in $referenceElements)
+    #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+    #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+    #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}());
+  #end
+                $field = ${otherTablePeerName}.doSelect(criteria, con);
+            }
+        }
+        else
+        {
+             // criteria has no effect for a new object
+            if (!isNew())
+            {
+                // the following code is to determine if a new query is
+                // called for.  If the criteria is the same as the last
+                // one, just return the collection.
+#end
+#foreach ($referenceElement in $referenceElements)
+  #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+  #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+  #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+  #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}());
+#end
+#if ($objectIsCaching)
+                if (!${criteriaCacheField}.equals(criteria))
+                {
+                    $field = ${otherTablePeerName}.doSelect(criteria, con);
+                }
+            }
+        }
+        ${criteriaCacheField} = criteria;
+
+        return $field;
+#else
+        return ${otherTablePeerName}.doSelect(criteria, con);
+#end
+    }
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,38 @@
+## 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 creates the initializer method in the object for the 
+## "foreign" part of a foreign key. The initialized object collection represents
+## the "local" side of the foreign key.  
+## The template expects as input a "foreign-field" element inside a 
+## "foreign-key" element from the torque schema, which was generated 
+## by the OMTransformer.  
+##
+    /**
+     * Initializes the cache $field for referenced objects. 
+     */
+    protected void ${initializer}()
+    {
+        if ($field == null)
+        {
+            $field = new ${initializerType}();
+        }
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/joinGetterReferencingObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/joinGetterReferencingObject.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/joinGetterReferencingObject.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/joinGetterReferencingObject.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,214 @@
+## 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 creates the getter method using a join in the object 
+## for the "foreign" part of a foreign key. The objects in the field 
+## represent the "local" part of the foreign key.  
+## The template expects as input a "foreign-field" element inside a 
+## "foreign-key" element from the torque schema, which was generated 
+## by the OMTransformer.  
+##
+#set ( $silentDbFetch = $torqueGf.booleanOption("torque.om.silentDbFetch") )
+#set ( $objectIsCaching = $torqueGf.booleanOption("torque.om.objectIsCaching") )
+#set ( $foreignKeyElement = $torqueGf.getParent() )
+#set ( $otherTable = $foreignKeyElement.getParent() )
+#set ( $otherTablePeerClass = $otherTable.getAttribute("peerClassName") )
+#set ( $otherTablePeerPackage = $otherTable.getAttribute("peerPackage") )
+#set ( $otherTablePeerName = "${otherTablePeerPackage}.${otherTablePeerClass}" )
+#set ( $thisTableElement = $foreignKeyElement.getChild("table") )
+#set ( $thisObjectClassName = $thisTableElement.getAttribute("baseDbObjectClassName") )
+#set ( $referenceElements = $foreignKeyElement.getChildren("reference") )
+#if ($silentDbFetch)
+    /**
+  #if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName is new, it will return
+  #else
+     * If this $thisObjectClassName is new, this method will return
+  #end
+     * an empty collection; or if this thisObjectClassName has previously
+     * been saved, it will retrieve the related objects from storage.
+     *
+     * This method is protected by default in order to keep the public
+     * api reasonable.  You can change the access modifier to public
+     * by overriding this method in the child class.
+     */
+    protected $fieldType ${joinGetter}(Criteria criteria) throws TorqueException
+    {
+        return ${joinGetter}(criteria, null);
+    }
+
+#end
+    /**
+#if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName is new, it will return
+#else
+     * If this $thisObjectClassName is new, this method will return
+#end
+     * an empty collection; or if this $thisObjectClassName has previously
+     * been saved, it will retrieve the related objects from storage.
+     *
+     * This method is protected by default in order to keep the public
+     * api reasonable.  You can change the access modifier to public
+     * by overriding this method in the child class.
+     */
+    protected $fieldType ${joinGetter}(Criteria criteria, Connection connection)
+        throws TorqueException
+    {
+#if ($objectIsCaching)
+        if ($field == null)
+        {
+            if (isNew())
+            {
+                ${initializer}();
+            }
+            else
+            {
+  #foreach ($referenceElement in $referenceElements)
+    #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+    #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+    #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+  #end
+                $field = ${otherTablePeerName}.${peerJoinSelectMethod}(criteria, connection);
+            }
+        }
+        else
+        {
+            // the following code is to determine if a new query is
+            // called for.  If the criteria is the same as the last
+            // one, just return the collection.
+#end
+#foreach ($referenceElement in $referenceElements)
+  #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+  #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+  #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+  #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+            criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+#end
+#if ($objectIsCaching)
+            if (!${criteriaCacheField}.equals(criteria))
+            {
+                $field = ${otherTablePeerName}.${peerJoinSelectMethod}(criteria, connection);
+            }
+        }
+        $criteriaCacheField = criteria;
+
+        return $field;
+#else
+        return ${otherTablePeerName}.${peerJoinSelectMethod}(criteria, connection);
+#end
+    }
+    
+#if ($thisTableElement.getChildren("referencing-foreign-keys").size() > 2)
+  #if ($silentDbFetch)
+    /**
+    #if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName is new, it will return
+    #else
+     * If this $thisObjectClassName is new, this method will return
+    #end
+     * an empty collection; or if this $thisObjectClassName has previously
+     * been saved, it will retrieve related objects from the database.
+     *
+     * This method is protected by default in order to keep the public
+     * api reasonable.  You can change the access modifier to public
+     * by overriding this method in the child class.
+     */
+    protected $fieldType ${joinAllExceptGetter}(Criteria criteria)
+        throws TorqueException
+    {
+        $fieldType ${joinAllExceptGetter}(Criteria criteria, null);
+    }
+
+  #end
+    /**
+  #if ($objectIsCaching)
+     * If this collection has already been initialized with
+     * an identical criteria, it returns the collection.
+     * Otherwise if this $thisObjectClassName is new, it will return
+  #else
+     * If this $thisObjectClassName is new, this method will return
+  #end
+     * an empty collection; or if this $thisObjectClassName has previously
+     * been saved, it will retrieve related objects from the database.
+     *
+     * This method is protected by default in order to keep the public
+     * api reasonable.  You can change the access modifier to public
+     * by overriding this method in the child class.
+     */
+    protected $fieldType ${joinAllExceptGetter}(Criteria criteria, Connection connection)
+        throws TorqueException
+    {
+  #if ($objectIsCaching)
+        if ($field == null)
+        {
+            if (isNew())
+            {
+                ${initializer}();
+            }
+            else
+            {
+    #foreach ($referenceElement in $referenceElements)
+      #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+      #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+      #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+      #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+                criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+    #end
+                $field = ${otherTablePeerName}.${peerJoinAllExceptSelectMethod}(criteria, connection);
+            }
+        }
+        else
+        {
+            // the following code is to determine if a new query is
+            // called for.  If the criteria is the same as the last
+            // one, just return the collection.
+  #end
+  #foreach ($referenceElement in $referenceElements)
+    #set ( $otherTableColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $thisTableColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+    #set ( $otherTablePeerColumnName = $otherTableColumnElement.getAttribute("peerColumnName") )
+    #set ( $thisTableColumnGetter = $thisTableColumnElement.getAttribute("getter") )
+            criteria.add(${otherTablePeerName}.${otherTablePeerColumnName}, ${thisTableColumnGetter}() );
+  #end
+  #if ($objectIsCaching)
+            if (!${criteriaCacheField}.equals(criteria))
+            {
+                $field = ${otherTablePeerName}.${peerJoinAllExceptSelectMethod}(criteria, connection);
+            }
+        }
+        $criteriaCacheField = criteria;
+
+        return $field;
+  #else
+        return ${otherTablePeerName}.${peerJoinAllExceptSelectMethod}(criteria, connection);
+  #end
+    }
+
+  #end
+

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/peerGetter.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/peerGetter.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/peerGetter.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/peerGetter.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,39 @@
+## 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 getter for the Peer for a database base object.
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+    /** The Peer class */
+    private static final $peerPackage.$peerClassName peer
+            = new $peerPackage.$peerClassName();
+
+    /**
+     * returns a peer instance associated with this om.  Since Peer classes
+     * are not to have any instance attributes, this method returns the
+     * same instance for all member of this class. The method could therefore
+     * be static, but this would prevent one from overriding the behavior.
+     */
+    public ${peerPackage}.${peerClassName} getPeer()
+    {
+        return peer;
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,252 @@
+## 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 creates primary key methods.  
+## The template expects as input a "table" element from the torque schema, 
+## which was processed by the OMTransformer.  
+##
+#set ( $throwsClause = "" )
+#set ( $argList = "" )
+#set ( $argList2 = "" )
+#set ( $comma = "" )
+#foreach ($col in $table.PrimaryKey)
+  #if ($complexObjectModel)
+    #if ( $col.isForeignKey() || ($col.Referrers.size() > 0) )
+      #set ( $throwsClause = "throws TorqueException" )
+    #end
+  #end
+  #set ( $clo=$col.UncapitalisedJavaName )
+  #set ( $cjtype = $col.JavaNative )
+  #set ($argList = "${argList}$comma $cjtype $clo")
+  #set ($argList2 = "${argList2}$comma String $clo")
+  #set ( $comma = "," )
+#end
+
+#set ( $primaryKeyColumnElements = $torqueGf.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 ( $setter = $columnElement.getAttribute("setter") )
+  #set ( $number = $columnElement.getAttribute("number") )
+  #set ( $primitive = $columnElement.getAttribute("primitive") )
+    /**
+     * Set the PrimaryKey using ObjectKey.
+     *
+     * @param key $field ObjectKey
+     */
+    public void setPrimaryKey(ObjectKey key)
+        $throwsClause
+    {
+  #if($fieldType == "java.math.BigDecimal")
+        ${setter}(((NumberKey) key).getBigDecimal());
+  #elseif ($number == "true")
+    #if ($primitive == "true")
+        ${setter}(((NumberKey) key).${fieldType}Value());
+    #else
+      #if ($fieldType == "integer")
+        #set ( $valueMethod = "intValue")
+      #else
+        #set ( $valueMethod = "${fieldType.substring(0,1).toLowerCase()}${fieldType.substring(1)}Value" )
+      #end
+        ${setter}(new ${fieldType}(((NumberKey) key).${valueMethod}()));
+    #end
+  #elseif($fieldType == "String")
+        ${setter}(key.toString());
+  #elseif($fieldType == "java.util.Date")
+        ${setter}(((DateKey) key).getDate());
+  #else
+        ${setter}(($fieldType) key);
+  #end
+    }
+
+    /**
+     * Set the PrimaryKey using a String.
+     *
+     * @param key
+     */
+    public void setPrimaryKey(String key) $throwsClause
+    {
+  #if($fieldType == "java.math.BigDecimal")
+        ${setter}(new $fieldType(key));
+  #elseif ($fieldType == "short")
+        ${setter}(Short.parseShort(key));
+  #elseif($fieldType == "int")
+        ${setter}(Integer.parseInt(key));
+  #elseif($fieldType == "long")
+        ${setter}(Long.parseLong(key));
+  #elseif($fieldType == "java.math.BigDecimal")
+        ${setter}(new $fieldType(key));
+  #elseif($fieldType == "byte")
+        ${setter}(Byte.parseByte(key));
+  #elseif($fieldType == "float")
+        ${setter}(Float.parseFloat(key));
+  #elseif($fieldType == "double")
+        ${setter}(Double.parseDouble(key));
+  #elseif ($number == "true" && ($primitive != "true"))
+        ${setter}(new ${fieldType}(key));
+  #elseif($fieldType == "String")
+        ${setter}(key);
+  #elseif($fieldType == "java.util.Date")
+        ${setter}(new ${fieldType}(key));
+  #else
+        ${setter}(($fieldType) key);
+  #end
+    }
+
+#elseif ($primaryKeyColumnElements.size() > 1)
+
+    private final SimpleKey[] pks = new SimpleKey[$primaryKeyColumnElements.size()];
+    private final ComboKey comboPK = new ComboKey(pks);
+
+    /**
+     * Set the PrimaryKey with an ObjectKey
+     *
+     * @param key
+     */
+    public void setPrimaryKey(ObjectKey key) throws TorqueException
+    {
+        SimpleKey[] keys = (SimpleKey[]) key.getValue();
+  #set ($i = 0)
+  #foreach ($columnElement in $primaryKeyColumnElements)
+    #set ( $field = $columnElement.getAttribute("field") )
+    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+    #set ( $setter = $columnElement.getAttribute("setter") )
+    #set ( $number = $columnElement.getAttribute("number") )
+    #set ( $primitive = $columnElement.getAttribute("primitive") )
+    #if($fieldType == "java.math.BigDecimal")
+        ${setter}(((NumberKey) keys[$i]).getBigDecimal());
+    #elseif ($number == "true")
+      #if ($primitive == "true")
+        ${setter}(((NumberKey) keys[$i]).${fieldType}Value());
+      #else
+        ${setter}(new ${fieldType}((NumberKey) keys[$i]).${fieldType}Value());
+      #end
+    #elseif($fieldType == "String")
+        ${setter}(keys[$i].toString());
+    #elseif($fieldType == "Date")
+        ${setter}(((DateKey) keys[$i]).getDate());
+    #else
+        ${setter}(($fieldType) keys[$i]);
+    #end
+    #set ( $i = $i + 1 )
+  #end
+    }
+
+    /**
+     * Set the PrimaryKey using SimpleKeys.
+     *
+  #set ( $argList = "" )
+  #foreach ($columnElement in $primaryKeyColumnElements)
+    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+    #set ( $field = $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
+  #end
+     */
+    public void setPrimaryKey($argList)
+        $throwsClause
+    {
+  #foreach ($columnElement in $primaryKeyColumnElements)
+    #set ( $setter = $columnElement.getAttribute("setter") )
+    #set ( $field = $columnElement.getAttribute("field") )
+        ${setter}($field);
+  #end
+    }
+
+    /**
+     * Set the PrimaryKey using a String.
+     */
+    public void setPrimaryKey(String key) throws TorqueException
+    {
+        setPrimaryKey(new ComboKey(key));
+    }
+#end
+
+    /**
+     * returns an id that differentiates this object from others
+     * of its class.
+     */
+    public ObjectKey getPrimaryKey()
+    {
+#if ($primaryKeyColumnElements.size() == 1)
+  #set ( $columnElement = $primaryKeyColumnElements.get(0) )
+  #set ( $getter = $columnElement.getAttribute("getter") )
+        return SimpleKey.keyFor(${getter}());
+#elseif ($primaryKeyColumnElements.size() > 1)
+        SimpleKey[] pks = new SimpleKey[$primaryKeyColumnElements.size()];
+  #set ($i = 0)
+  #foreach ($columnElement in $primaryKeyColumnElements)
+    #set ( $getter = $columnElement.getAttribute("getter") )
+        pks[$i] = SimpleKey.keyFor(${getter}());
+    #set ($i = $i + 1)
+  #end
+        return new ComboKey(pks);
+#else
+        return null;
+#end
+    }
+
+#if ($torqueGf.booleanOption("torque.om.addIntakeRetrievable"))
+    /**
+     * get an id that differentiates this object from others
+     * of its class.
+     */
+    public String getQueryKey()
+    {
+        if (getPrimaryKey() == null)
+        {
+            return "";
+        }
+        else
+        {
+            return getPrimaryKey().toString();
+        }
+    }
+
+    /**
+     * set an id that differentiates this object from others
+     * of its class.
+     */
+    public void setQueryKey(String key)
+        throws TorqueException
+    {
+  ## Work around the fact that BaseObject.setPrimaryKey() declares
+  ## that it throws Exception instead of TorqueException.
+  #if ($primaryKeyColumnElements.isEmpty())
+        try
+        {
+  #end
+        setPrimaryKey(key);
+  #if ($primaryKeyColumnElements.isEmpty())
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException("Unable to set query key", e);
+        }
+  #end
+    }
+#end

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/referencingObjectMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/referencingObjectMethods.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/referencingObjectMethods.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/referencingObjectMethods.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,38 @@
+## 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 is invoked in the object representing the "foreign"
+## part of a foreign key. It creates the methods which allow access for the 
+## "local" side objects of a foreign key. 
+## The template expects as input a "foreign-field" element inside a 
+## "foreign-key" element from the torque schema, which was generated 
+## by the OMTransformer.  
+##
+#set ( $objectIsCaching = $torqueGf.booleanOption("torque.om.objectIsCaching") )
+#if ($objectIsCaching)
+$torqueGf.mergepoint("initializer")
+$torqueGf.mergepoint("adder")
+#end
+$torqueGf.mergepoint("getter")
+#if ($objectIsCaching)
+$torqueGf.mergepoint("setter")
+#end
+$torqueGf.mergepoint("referencingJoinGetters")

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,190 @@
+## 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 creates save methods for a BaseDbObject.
+## The template expects as input a "table" element from the torque schema, 
+## which was processed by the OMTransformer.  
+##
+#set ( $complexObjectModel = $torqueGf.booleanOption("torque.om.complexObjectModel") )
+#set ( $objectIsCaching = $torqueGf.booleanOption("torque.om.objectIsCaching") )
+#set ( $saveException = $torqueGf.option("torque.om.save.saveException") )
+    /**
+     * Stores the object in the database.  If the object is new,
+     * it inserts it; otherwise an update is performed.
+     *
+     * @throws $saveException
+     */
+    public void save() throws $saveException
+    {
+#if ($complexObjectModel)
+        save(${peerClassName}.DATABASE_NAME);
+#else
+        if (isModified())
+        {
+            if (isNew())
+            {
+                ${peerClassName}.doInsert(($dbObjectClassName) this);
+                setNew(false);
+            }
+            else
+            {
+                ${peerClassName}.doUpdate(($dbObjectClassName) this);
+            }
+        }
+#end
+    }
+
+    /**
+     * Stores the object in the database.  If the object is new,
+     * it inserts it; otherwise an update is performed.
+#if ($complexObjectModel)
+     * Note: this code is here because the method body is
+     * auto-generated conditionally and therefore needs to be
+     * in this file instead of in the super class, BaseObject.
+#end
+     *
+     * @param dbName
+     * @throws TorqueException
+     */
+    public void save(String dbName) throws TorqueException
+    {
+        Connection con = null;
+#if ($complexObjectModel)
+        try
+        {
+            con = Transaction.begin(dbName);
+            save(con);
+            Transaction.commit(con);
+        }
+        catch(TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw e;
+        }
+#else
+        if (isModified())
+        {
+            try
+            {
+                con = Torque.getConnection(dbName);
+                if (isNew())
+                {
+                    ${peerClassName}.doInsert(this, con);
+                    setNew(false);
+                }
+                else
+                {
+                    ${peerClassName}.doUpdate(this, con);
+                }
+            }
+            finally
+            {
+                Torque.closeConnection(con);
+            }
+        }
+  #end
+    }
+
+#if ($complexObjectModel && $objectIsCaching)
+    /** flag to prevent endless save loop, if this object is referenced
+        by another object which falls in this transaction. */
+    private boolean alreadyInSave = false;
+
+#end
+    /**
+     * Stores the object in the database.  If the object is new,
+     * it inserts it; otherwise an update is performed.  This method
+     * is meant to be used as part of a transaction, otherwise use
+     * the save() method and the connection details will be handled
+     * internally
+     *
+     * @param con
+     * @throws TorqueException
+     */
+    public void save(Connection con) throws TorqueException
+    {
+#if ($complexObjectModel && $objectIsCaching)
+        if (!alreadyInSave)
+        {
+            alreadyInSave = true;
+#end
+            // If this object has been modified, then save it to the database.
+            if (isModified())
+            {
+                if (isNew())
+                {
+                    ${peerClassName}.doInsert(($dbObjectClassName) this, con);
+                    setNew(false);
+                }
+                else
+                {
+                    ${peerClassName}.doUpdate(($dbObjectClassName) this, con);
+                }
+#if ($torqueGf.booleanOption("torque.om.useManagers"))
+  #set ( $primaryKeyColumnElements = $torqueGf.getChild("primary-keys").getChildren("column") )
+  #if ( $primaryKeyColumnElements.size() != 0)
+                if (isCacheOnSave())
+                {
+                    ${managerPackage}.${managerClassName}.putInstance(this);
+                }
+  #end
+#end
+            }
+
+#if ($complexObjectModel && $objectIsCaching)
+  #set ( $referencingForeignKeyElements = $torqueGf.getChild("referencing-foreign-keys").getChildren("foreign-key") )
+  #set ( $thisTableName = $torqueGf.getSourceElement().getAttribute("name"))
+  #foreach ($referencingForeignKeyElement in $referencingForeignKeyElements)
+    #set ( $otherTable = $referencingForeignKeyElement.getParent())
+    #set ( $otherTableName = $otherTable.getAttribute("name"))
+    #if ( !($thisTableName.equals($otherTableName)) )
+      #set ( $otherClassName = $otherTable.getAttribute("baseDbObjectClassName") )
+      #set ( $relCol = "" )
+      #set ( $field = $referencingForeignKeyElement.getChild("foreign-field").getAttribute("field"))
+            if ($field != null)
+            {
+                for (int i = 0; i < ${field}.size(); i++)
+                {
+                    ((${otherClassName}) ${field}.get(i)).save(con);
+                }
+            }
+    #end
+  #end
+            alreadyInSave = false;
+        }
+#end
+    }
+
+#if ($torqueGf.booleanOption("torque.om.useManagers"))
+  #set ( $primaryKeyColumnElements = $torqueGf.getChild("primary-keys").getChildren("column") )
+  #if ( $primaryKeyColumnElements.size() != 0)
+
+    /**
+     * Specify whether to cache the object after saving to the db.
+     * This method returns true
+     */
+    protected boolean isCacheOnSave()
+    {
+        return true;
+    }
+  #end
+#end
+

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/setterReferencedObjectByObjectKey.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/setterReferencedObjectByObjectKey.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/setterReferencedObjectByObjectKey.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/setterReferencedObjectByObjectKey.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,93 @@
+## 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 creates setters for setting related objects via ObjectKeys
+## in a BaseDbObject.
+## The template expects as input a "table/foreign-key/local-field" element
+## from the torque schema, which was processed by the OMTransformer.  
+##
+#set ( $foreignKeyElement = $torqueGf.getParent() )
+#set ( $localTableElement = $foreignKeyElement.getParent() )
+#set ( $foreignTableElement = $foreignKeyElement.getChild("table") )
+#set ( $referenceElements = $foreignKeyElement.getChildren("reference") )
+    /**
+     * Provides convenient way to set a relationship based on a
+     * ObjectKey, for example
+     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
+     *
+#if ($referenceElements.size() > 1)
+     * Note: It is important that the xml schema used to create this class
+     * maintains consistency in the order of related columns between
+     * $localTableElement.getAttribute("name") and $foreignTableElement.getAttribute("name").
+     * If for some reason this is impossible, this method should be
+     * overridden in <code>$localTableElement.getAttribute("javaName")</code>.
+#end
+     */
+    public void ${setter}Key(ObjectKey key) throws TorqueException
+    {
+#if ($referenceElements.size() > 1)
+        SimpleKey[] keys = (SimpleKey[]) key.getValue();
+#end
+       
+#set ($i = 0)
+#foreach ($referenceElement in $referenceElements)
+  #if ($referenceElements.size() > 1)
+    #set ($keyVariable = "keys[$i]" )        
+  #else
+    #set ($keyVariable = "key" )        
+  #end
+  #set ( $localColumnElement = $referenceElement.getChild("local-column").getChild("column") )
+  #set ( $localFieldType = $localColumnElement.getAttribute("fieldType") )
+  #set ( $localFieldSetter = $localColumnElement.getAttribute("setter") )
+  #if ($localFieldType == "short")
+        ${localFieldSetter}(((NumberKey) $keyVariable).shortValue());
+  #elseif ($localFieldType == "int")
+        ${localFieldSetter}(((NumberKey) $keyVariable).intValue());
+  #elseif ($localFieldType == "long")
+        ${localFieldSetter}(((NumberKey) $keyVariable).longValue());
+  #elseif ($localFieldType == "java.math.BigDecimal")
+        ${localFieldSetter}(((NumberKey) $keyVariable).getBigDecimal());
+  #elseif ($localFieldType == "byte")
+        ${localFieldSetter}(((NumberKey) $keyVariable).byteValue());
+  #elseif ($localFieldType == "float")
+        ${localFieldSetter}(((NumberKey) $keyVariable).floatValue());
+  #elseif ($localFieldType == "double")
+        ${localFieldSetter}(((NumberKey) $keyVariable).doubleValue());
+  #elseif ($localFieldType == "Short")
+        ${localFieldSetter}(new Short(((NumberKey) $keyVariable).shortValue()));
+  #elseif ($localFieldType == "Integer")
+        ${localFieldSetter}(new Integer(((NumberKey) $keyVariable).intValue()));
+  #elseif ($localFieldType == "Long")
+        ${localFieldSetter}(new Long(((NumberKey) $keyVariable).longValue()));
+  #elseif ($localFieldType == "Byte")
+        ${localFieldSetter}(new Byte(((NumberKey) $keyVariable).byteValue()));
+  #elseif ($localFieldType == "Float")
+        ${localFieldSetter}(new Float(((NumberKey) $keyVariable).floatValue()));
+  #elseif ($localFieldType == "Double")
+        ${localFieldSetter}(new Double(((NumberKey) $keyVariable).doubleValue()));
+  #elseif ($localFieldType == "String")
+        ${localFieldSetter}(${keyVariable}.toString());
+  #elseif ($localFieldType == "Date")
+        ${localFieldSetter}(((DateKey)$keyVariable).getDate());
+  #end
+  #set ( $i = $i + 1 )
+#end ## end of foreach loop over references
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/tableMapGetter.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/tableMapGetter.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/tableMapGetter.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/tableMapGetter.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,35 @@
+## 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 getter for the Table Map for a database base object.
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+    /**
+     * Retrieves the TableMap object related to this Table data without
+     * compiler warnings of using getPeer().getTableMap().
+     *
+     * @return The associated TableMap object.
+     */
+    public TableMap getTableMap() throws TorqueException
+    {
+        return ${peerPackage}.${peerClassName}.getTableMap();
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,44 @@
+## 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 creates the toString method for a database object.
+## The template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+    public String toString()
+    {
+        StringBuffer str = new StringBuffer();
+        str.append("$dbObjectClassName:\n");
+#set ( $columnElements = $torqueGf.getChildren("column") )
+#foreach ($columnElement in $columnElements)
+  #set ( $field = $columnElement.getAttribute("field") )
+  #set ( $fieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $getter = $columnElement.getAttribute("getter") )
+        str.append("$field = ")
+  #if ( $fieldType == "byte[]" )
+           .append("<binary>")
+  #else
+           .append(${getter}())
+  #end
+           .append("\n");
+#end
+        return(str.toString());
+    }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/classJavadoc.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/classJavadoc.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/classJavadoc.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/classJavadoc.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,40 @@
+## 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 class javadoc for a database object. 
+## This template expects as input a "table" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+/**
+#if ($description)
+ * $description
+ *
+#end
+#if ($torqueGf.booleanOption("torque.om.addTimeStamp"))
+ * The skeleton for this class was autogenerated by Torque on:
+ *
+ * [${torqueGf.now()}]
+ *
+#end
+ * You should add additional methods to this class to meet the
+ * application requirements.  This class will only be generated as
+ * long as it does not already exist in the output directory.
+ */



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