db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1414363 [1/2] - in /db/torque/torque4/trunk: torque-templates/src/main/java/org/apache/torque/templates/ torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ torque-templates/src/main/resources/org/apache/torque/templ...
Date Tue, 27 Nov 2012 20:02:37 GMT
Author: tfischer
Date: Tue Nov 27 20:02:32 2012
New Revision: 1414363

URL: http://svn.apache.org/viewvc?rev=1414363&view=rev
Log:
TORQUE-182 Additional methods for handling associated objects
TORQUE-249 add valueEquals method 

Added:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/valueEquals.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setAndSaveReferencing.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java   (with props)
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java   (with props)
Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FieldHelper.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/basePeer.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peerImpl.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObjectForView.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
    db/torque/torque4/trunk/torque-test/src/main/schema/foreign-key-schema.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java Tue Nov 27 20:02:32 2012
@@ -108,6 +108,12 @@ public enum TemplateOptionName implement
     /** The name of the option for the suffix of the filler methods. */
     OM_FILLER_SUFFIX("torque.om.complexObjectModel.fillerSuffix"),
 
+    /** The name of the option for the prefix of the setAndSave methods. */
+    OM_SET_AND_SAVE_PREFIX("torque.om.complexObjectModel.setAndSavePrefix"),
+
+    /** The name of the option for the suffix of the setAndSave methods. */
+    OM_SET_AND_SAVE_SUFFIX("torque.om.complexObjectModel.setAndSaveSuffix"),
+
     /**
      * The name of the option for the part added to the referencing
      * direction if naming conflicts occur.

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FieldHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FieldHelper.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FieldHelper.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FieldHelper.java Tue Nov 27 20:02:32 2012
@@ -176,7 +176,7 @@ final class FieldHelper
      *        naming conflicts, not null.
      * @param controllerState the current controller state, not null.
      *
-     * @return the initializer method name, not null.
+     * @return the filler method name, not null.
      */
     public static String getFillerName(
             String fieldName,
@@ -192,4 +192,29 @@ final class FieldHelper
                   TemplateOptionName.OM_FILLER_SUFFIX);
         return fillerName;
     }
+
+    /**
+     * Returns the name of the setAndSave method for a field.
+     *
+     * @param fieldName the name of the field, not null.
+     * @param distinctionPart a possible distinction addition for resolving
+     *        naming conflicts, not null.
+     * @param controllerState the current controller state, not null.
+     *
+     * @return the setAndSave method name, not null.
+     */
+    public static String getSetAndSaveMethodName(
+            String fieldName,
+            String distinctionPart,
+            ControllerState controllerState)
+    {
+        String fillerName
+            = controllerState.getOption(
+                    TemplateOptionName.OM_SET_AND_SAVE_PREFIX)
+                + distinctionPart
+                + StringUtils.capitalize(fieldName)
+                + controllerState.getOption(
+                  TemplateOptionName.OM_SET_AND_SAVE_SUFFIX);
+        return fillerName;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java Tue Nov 27 20:02:32 2012
@@ -264,6 +264,16 @@ public class OMForeignKeyTransformer
                         fillerName);
             }
             {
+                String setAndSaveMethodName
+                    = FieldHelper.getSetAndSaveMethodName(
+                        getterSetterFieldName,
+                        "",
+                        controllerState);
+                foreignFieldElement.setAttribute(
+                        "setAndSaveMethodName",
+                        setAndSaveMethodName);
+            }
+            {
                 // Name for a getter in the foreign table to
                 // retrieve entries in the foreign table plus the joined
                 // entries in the local table.

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties Tue Nov 27 20:02:32 2012
@@ -185,6 +185,11 @@ torque.om.complexObjectModel.fillerSuffi
 # filler methods for referencing and referenced objects have the same name
 torque.om.complexObjectModel.fillerReferencingDistinction = Referencing
 
+# The prefix of the setAndSave methods.
+torque.om.complexObjectModel.setAndSavePrefix = setAndSave
+# The suffix of the setAndSave methods. */
+torque.om.complexObjectModel.setAndSaveSuffix = s
+
 # The default chunk size for the filler methods.
 torque.om.complexObjectModel.defaultFillerChunkSize=999
 

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/basePeer.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/basePeer.xml?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/basePeer.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/basePeer.xml Tue Nov 27 20:02:32 2012
@@ -128,6 +128,11 @@
           element="referencing-foreign-keys/foreign-key/foreign-field"
           outlet="torque.om.peer.base.fillReferencingObjects"/>
     </mergepoint>
+    <mergepoint name="setAndSaveReferencing">
+      <action xsi:type="traverseAllAction"
+          element="referencing-foreign-keys/foreign-key/foreign-field"
+          outlet="torque.om.peer.base.setAndSaveReferencing"/>
+    </mergepoint>
     <mergepoint name="getTableMap">
       <action xsi:type="applyAction" outlet="torque.om.peer.base.getTableMap"/>
     </mergepoint>
@@ -413,6 +418,11 @@
       path="peer/base/fillReferencingObjects.vm">
   </outlet>
 
+  <outlet name="torque.om.peer.base.setAndSaveReferencing"
+      xsi:type="velocityOutlet"
+      path="peer/base/setAndSaveReferencing.vm">
+  </outlet>
+
   <outlet name="torque.om.peer.base.getTableMap"
       xsi:type="velocityOutlet"
       path="peer/base/getTableMap.vm">

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml Tue Nov 27 20:02:32 2012
@@ -166,6 +166,10 @@
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.equalsHashCode"/>
     </mergepoint>
+    <mergepoint name="valueEquals">
+      <action xsi:type="applyAction"
+          outlet="torque.om.dbObject.base.valueEquals"/>
+    </mergepoint>
     <mergepoint name="toString">
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.toString"/>
@@ -240,6 +244,10 @@
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.equalsHashCode"/>
     </mergepoint>
+    <mergepoint name="valueEquals">
+      <action xsi:type="applyAction"
+          outlet="torque.om.dbObject.base.valueEquals"/>
+    </mergepoint>
     <mergepoint name="toString">
       <action xsi:type="applyAction"
           outlet="torque.om.dbObject.base.toString"/>
@@ -445,6 +453,11 @@
       path="dbObject/base/equalsHashCode.vm">
   </outlet>
 
+  <outlet name="torque.om.dbObject.base.valueEquals"
+      xsi:type="velocityOutlet"
+      path="dbObject/base/valueEquals.vm">
+  </outlet>
+
   <outlet name="torque.om.dbObject.base.toString"
       xsi:type="velocityOutlet"
       path="dbObject/base/toString.vm">

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peerImpl.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peerImpl.xml?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peerImpl.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peerImpl.xml Tue Nov 27 20:02:32 2012
@@ -107,6 +107,11 @@
           element="referencing-foreign-keys/foreign-key/foreign-field"
           outlet="torque.om.peer.impl.base.fillReferencingObjects"/>
     </mergepoint>
+    <mergepoint name="setAndSaveReferencing">
+      <action xsi:type="traverseAllAction"
+          element="referencing-foreign-keys/foreign-key/foreign-field"
+          outlet="torque.om.peer.impl.base.setAndSaveReferencing"/>
+    </mergepoint>
     <mergepoint name="extensions" />
   </outlet>
 
@@ -239,4 +244,8 @@
       path="peer/impl/base/fillReferencingObjects.vm">
   </outlet>
 
+  <outlet name="torque.om.peer.impl.base.setAndSaveReferencing"
+      xsi:type="velocityOutlet"
+      path="peer/impl/base/setAndSaveReferencing.vm">
+  </outlet>
 </outlets>
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm Tue Nov 27 20:02:32 2012
@@ -116,5 +116,6 @@ $torqueGen.mergepoint("getCurrentTimesta
 
 $torqueGen.mergepoint("toString")
 $torqueGen.mergepoint("equalsHashCode")
+$torqueGen.mergepoint("valueEquals")
 $torqueGen.mergepoint("extensions")
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObjectForView.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObjectForView.vm?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObjectForView.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObjectForView.vm Tue Nov 27 20:02:32 2012
@@ -129,5 +129,6 @@ $torqueGen.mergepoint("objectBeanMethods
 
 $torqueGen.mergepoint("toString")
 $torqueGen.mergepoint("equalsHashCode")
+$torqueGen.mergepoint("valueEquals")
 $torqueGen.mergepoint("extensions")
 }

Modified: 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=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm Tue Nov 27 20:02:32 2012
@@ -94,7 +94,7 @@ $torqueGen.mergepoint("createObjectInsta
      *
      * @param copyObj the object to fill.
      */
-    protected $dbObjectClassName copyInto($dbObjectClassName copyObj) throws TorqueException
+    public $dbObjectClassName copyInto($dbObjectClassName copyObj) throws TorqueException
     {
         return copyInto(copyObj, true);
     }
@@ -106,7 +106,7 @@ $torqueGen.mergepoint("createObjectInsta
      * @param copyObj the object to fill.
      * @param con the database connection to read associated objects.
      */
-    protected $dbObjectClassName copyInto($dbObjectClassName copyObj, Connection con) throws TorqueException
+    public $dbObjectClassName copyInto($dbObjectClassName copyObj, Connection con) throws TorqueException
     {
         return copyInto(copyObj, true, con);
     }
@@ -199,7 +199,7 @@ $torqueGen.mergepoint("createObjectInsta
      * @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
+    public $dbObjectClassName copyInto($dbObjectClassName copyObj, boolean deepcopy, Connection con) throws TorqueException
     {
   #set ( $columnElements = $torqueGen.getChildren("column") )
   #foreach ($columnElement in $columnElements)

Modified: 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=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/initializerReferencingObject.vm Tue Nov 27 20:02:32 2012
@@ -27,12 +27,17 @@
 ## by the OMTransformer.  
 ##
     /**
-     * Initializes the cache $field for referenced objects. 
+     * Initializes the cache $field for referenced objects.
+     * This, means, if $field is null when this operation is called, it is
+     * initialized with an empty collection, otherwise it remains unchanged. 
+     *
+     * @return the (possibly new) content of the field $field, not null.
      */
-    public void ${initializer}()
+    public ${fieldType} ${initializer}()
     {
-        if ($field == null)
+        if (${field} == null)
         {
-            $field = new ${initializerType}();
+            ${field} = new ${initializerType}();
         }
+        return ${field};
     }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/valueEquals.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/valueEquals.vm?rev=1414363&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/valueEquals.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/valueEquals.vm Tue Nov 27 20:02:32 2012
@@ -0,0 +1,59 @@
+## 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: equalsHashCode.vm 1331196 2012-04-27 02:56:12Z tfischer $
+##
+## Creates the vLUWequals and hashCode methods.
+## This template expects as input a "table" element from the torque schema,
+## processed by the OM transformer
+##
+    /**
+     * Compares the content of this object to another object
+     *
+     * @param toCompare The object to compare to.
+     * @return true if all of the columns in the other object have 
+     *         the same value as the objects in this class.
+     */
+    public boolean valueEquals(${dbObjectClassName} toCompare)
+    {
+        if (toCompare == null)
+        {
+            return false;
+        }
+        if (this == toCompare)
+        {
+            return true;
+        }
+#set ( $columnElements = $torqueGen.getChildren("column") )
+#foreach ($columnElement in $columnElements)
+  #set ( $columnField = $columnElement.getAttribute("field") )
+  #set ( $getter = $columnElement.getAttribute("getter") )
+  #set ( $primitive = $columnElement.getAttribute("primitive") )
+  #if ($primitive == "true")
+        if (this.${columnField} != toCompare.${getter}())
+  #else
+        if (!ObjectUtils.equals(this.${columnField}, toCompare.${getter}()))
+  #end
+        {
+            return false;
+        }
+#end
+        return true;
+    }
+

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm Tue Nov 27 20:02:32 2012
@@ -76,6 +76,7 @@ $torqueGen.mergepoint("doSelectJoinAllEx
 $torqueGen.mergepoint("fillReferencedObjects")
 $torqueGen.mergepoint("fillReferencingObjects")
   #end
+$torqueGen.mergepoint("setAndSaveReferencing")
 #end
 $torqueGen.mergepoint("getTableMap")
 $torqueGen.mergepoint("initDatabaseMap")

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setAndSaveReferencing.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setAndSaveReferencing.vm?rev=1414363&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setAndSaveReferencing.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setAndSaveReferencing.vm Tue Nov 27 20:02:32 2012
@@ -0,0 +1,105 @@
+## 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: saveMethods.vm 1377465 2012-08-26 17:25:38Z tv $
+##
+## This template expects the current source element to be a "foreign-field" 
+## element from the schema, processed by the OMTransformer.
+## The options and the attributes of the current source element must be set
+## as velocity variables.
+##
+#set ( $foreignKeyElement = $torqueGen.getParent() )
+#set ( $localTableElement = $foreignKeyElement.getChild("table") )
+#set ( $peerImplGetter = $localTableElement.getAttribute("peerImplGetter") )
+#set ( $localDbObjectClassName = $localTableElement.getAttribute("dbObjectClassName") )
+#set ( $foreignTableElement = $foreignKeyElement.getParent() )
+#set ( $foreignDbObjectClassName = $foreignTableElement.getAttribute("dbObjectClassName") )
+#if ($foreignTableElement.getChild("primary-keys").getChildren().size() > 0)
+    /** 
+     * Saves the passed collection as linked objects.
+     * This means the following is done:
+     * <ul>
+     *  <li>
+     *    The current collection of linked objects with the same primary keys as
+     *    in toSave are read from the database into the list intersection.
+     *  </li>
+     *  <li>
+     *    All objects in toSave which are not in intersection are inserted.
+     *  </li>
+     *  <li>
+     *    All objects in intersection are updated with the corresponding values
+     *    in toSave and saved.
+     *  </li>
+     *  <li>
+     *    All objects in the database which are not in toSave are deleted.
+     *  </li>
+     *
+     * @param toLinkTo the object which collections should be set with the
+     *        values in toSave.
+     * @param toSave Contains the objects to save, not null, 
+     *        may not contain null.
+     *
+     * @throws TorqueException if an error accessing the database occurs.
+     * @throws NullPointerException if toFill is null or contains null elements.
+     */
+    public static void ${setAndSaveMethodName}(
+            ${localDbObjectClassName} toLinkTo,
+            Collection<${foreignDbObjectClassName}> toSave) 
+        throws TorqueException
+    {
+        ${peerImplGetter}().${setAndSaveMethodName}(toLinkTo, toSave);
+    }
+
+    /** 
+     * Saves the passed collection as linked objects.
+     * This means the following is done:
+     * <ul>
+     *  <li>
+     *    The current collection of linked objects with the same primary keys as
+     *    in toSave are read from the database into the list intersection.
+     *  </li>
+     *  <li>
+     *    All objects in toSave which are not in intersection are inserted.
+     *  </li>
+     *  <li>
+     *    All objects in intersection are updated with the corresponding values
+     *    in toSave and saved.
+     *  </li>
+     *  <li>
+     *    All objects in the database which are not in toSave are deleted.
+     *  </li>
+     *
+     * @param toLinkTo the object which collections should be set with the
+     *        values in toSave.
+     * @param toSave Contains the objects to save, not null, 
+     *        may not contain null.
+     * @param connection the database connection to use.
+     *
+     * @throws TorqueException if an error accessing the database occurs.
+     * @throws NullPointerException if toFill is null or contains null elements.
+     */
+    public void ${setAndSaveMethodName}(
+            ${localDbObjectClassName} toLinkTo,
+            Collection<${foreignDbObjectClassName}> toSave,
+            Connection connection) 
+        throws TorqueException
+    {
+        ${peerImplGetter}().${setAndSaveMethodName}(toLinkTo, toSave);
+    }
+#end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm Tue Nov 27 20:02:32 2012
@@ -64,6 +64,7 @@ $torqueGen.mergepoint("doSelectJoinAllEx
 $torqueGen.mergepoint("fillReferencedObjects")
 $torqueGen.mergepoint("fillReferencingObjects")
   #end
+$torqueGen.mergepoint("setAndSaveReferencing")
 #end
 $torqueGen.mergepoint("extensions")
 }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm?rev=1414363&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm Tue Nov 27 20:02:32 2012
@@ -0,0 +1,291 @@
+## 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: saveMethods.vm 1377465 2012-08-26 17:25:38Z tv $
+##
+## This template expects the current source element to be a "foreign-field" 
+## element from the schema, processed by the OMTransformer.
+## The options and the attributes of the current source element must be set
+## as velocity variables.
+##
+#set ( $foreignKeyElement = $torqueGen.getParent() )
+#set ( $foreignKeyGetter = $foreignKeyElement.getAttribute("foreignKeyGetter") )
+#set ( $referencesPrimaryKey = $foreignKeyElement.getAttribute("referencesPrimaryKey") )
+#set ( $foreignKeyReferences = $foreignKeyElement.getChildren("reference") )
+#set ( $localTableElement = $foreignKeyElement.getChild("table") )
+#set ( $localTableField = $localTableElement.getAttribute("field") )
+#set ( $localDbObjectClassName = $localTableElement.getAttribute("dbObjectClassName") )
+#set ( $localPeerClassName = $localTableElement.getAttribute("peerClassName") )
+#set ( $foreignTableElement = $foreignKeyElement.getParent() )
+#set ( $foreignTablePeerClassName = $foreignTableElement.getAttribute("peerClassName") )
+#set ( $foreignDbObjectClassName = $foreignTableElement.getAttribute("dbObjectClassName") )
+#set ( $foreignPrimaryKeyColumnElements = $foreignTableElement.getChild("primary-keys").getChildren("column"))
+#set ( $saveMethodsInDbObjects = $foreignTableElement.getAttribute("saveMethodsInDbObjects") )
+#if ($foreignTableElement.getChild("primary-keys").getChildren().size() > 0)
+    /** 
+     * Saves the passed collection as linked objects.
+     * This means the following is done:
+     * <ul>
+     *  <li>
+     *    The current collection of linked objects with the same primary keys as
+     *    in toSave are read from the database into the list intersection.
+     *  </li>
+     *  <li>
+     *    All objects in toSave which are not in intersection are inserted.
+     *  </li>
+     *  <li>
+     *    All objects in intersection are updated with the corresponding values
+     *    in toSave and saved.
+     *  </li>
+     *  <li>
+     *    All objects in the database which are not in toSave are deleted.
+     *  </li>
+     *
+     * @param toLinkTo the object which collections should be set with the
+     *        values in toSave.
+     * @param toSave Contains the objects to save, not null, 
+     *        may not contain null.
+     *
+     * @throws TorqueException if an error accessing the database occurs.
+     * @throws NullPointerException if toFill is null or contains null elements.
+     */
+    public void ${setAndSaveMethodName}(
+            ${localDbObjectClassName} toLinkTo,
+            Collection<${foreignDbObjectClassName}> toSave) 
+        throws TorqueException
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.begin(
+                    ${localPeerClassName}.DATABASE_NAME);
+            ${setAndSaveMethodName}(toLinkTo, toSave, connection);
+            Transaction.commit(connection);
+            connection = null;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
+    }
+
+    /** 
+     * Saves the passed collection as linked objects.
+     * This means the following is done:
+     * <ul>
+     *  <li>
+     *    The current collection of linked objects with the same primary keys as
+     *    in toSave are read from the database into the list intersection.
+     *  </li>
+     *  <li>
+     *    All objects in toSave which are not in intersection are inserted.
+     *  </li>
+     *  <li>
+     *    All objects in intersection are updated with the corresponding values
+     *    in toSave and saved.
+     *  </li>
+     *  <li>
+     *    All objects in the database which are not in toSave are deleted.
+     *  </li>
+     *
+     * @param toLinkTo the object which collections should be set with the
+     *        values in toSave.
+     * @param toSave Contains the objects to save, not null, 
+     *        may not contain null.
+     * @param connection the database connection to use.
+     *
+     * @throws TorqueException if an error accessing the database occurs.
+     * @throws NullPointerException if toFill is null or contains null elements.
+     */
+    public void ${setAndSaveMethodName}(
+            ${localDbObjectClassName} toLinkTo,
+            Collection<${foreignDbObjectClassName}> toSave,
+            Connection connection) 
+        throws TorqueException
+    {
+#if ($referencesPrimaryKey)
+        ObjectKey localKey = toLinkTo.getPrimaryKey();
+#else
+  #if ($foreignKeyReferences.size() == 1)
+    #set ( $localReferenceColumnElement = $foreignKeyReferences.get(0).getChild("foreign-column").getChild("column") )
+    #set ( $localFieldGetter = $localReferenceColumnElement.getAttribute("getter") )
+        ObjectKey localKey = SimpleKey.keyFor(toLinkTo.${localFieldGetter}());
+  #else
+        SimpleKey[] keyElementArray = new SimpleKey[$foreignKeyReferences.size()];
+    #set ($i = 0)
+    #foreach ($referenceElement in $foreignKeyReferences)
+      #set ( $localReferenceColumnElement = $referenceElement.getChild("foreign-column").getChild("column") )
+      #set ( $localFieldGetter = $localReferenceColumnElement.getAttribute("getter") )
+        keyElementArray[$i] = SimpleKey.keyFor(
+                toLinkTo.${localFieldGetter}());
+      #set ($i = $i + 1)
+    #end
+        ObjectKey localKey = new ComboKey(keyElementArray);
+  #end
+#end
+
+        Criteria criteria = new Criteria();
+#if ($foreignKeyReferences.size() == 1)
+  #set ( $columnElement = $foreignKeyReferences.get(0).getChild("local-column").getChild("column") )
+  #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+        Criterion onlyReferencingCriterion = new Criterion(
+                ${foreignTablePeerClassName}.${peerColumnName}, 
+                localKey);
+#else
+        SimpleKey[] keys = (SimpleKey[]) localKey.getValue();
+  #set ( $i = 0 )
+  #foreach ($referenceElement in $foreignKeyReferences)
+  #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+        Criterion c$i = new Criterion(
+                ${foreignTablePeerClassName}.${peerColumnName}, keys[$i]);
+    #set ( $j = $i - 1 )
+    #if ($i > 0)
+        c${j}.and(c${i});
+    #end
+    #set ( $i = $i + 1 )
+  #end
+        Criterion onlyReferencingCriterion = c0;
+#end
+        criteria.where(onlyReferencingCriterion);
+        Set<ObjectKey> toSaveKeys = new HashSet<ObjectKey>();
+        for (${foreignDbObjectClassName} toSaveElement : toSave)
+        {
+            ObjectKey toSaveKey = toSaveElement.getPrimaryKey();
+            if (toSaveKey.getValue() != null)
+            {
+                toSaveKeys.add(toSaveKey);
+            }
+        }
+#if ($foreignPrimaryKeyColumnElements.size() == 1)
+  #set ( $columnElement = $foreignPrimaryKeyColumnElements.get(0) )
+  #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+        criteria.and(${foreignTablePeerClassName}.${peerColumnName}, toSaveKeys, Criteria.IN);
+#else
+        Criterion toSaveKeyCriterion = null;
+        for (ObjectKey toSaveKey : toSaveKeys)
+        {
+            SimpleKey[] toSavePrimaryKeys = (SimpleKey[]) toSaveKey.getValue();
+  #set ( $i = 0 )
+  #foreach ($columnElement in $foreignPrimaryKeyColumnElements)
+  #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+            Criterion p$i = new Criterion(
+                    ${foreignTablePeerClassName}.${peerColumnName},
+                    toSavePrimaryKeys[$i]);
+    #set ( $j = $i - 1 )
+    #if ($i > 0)
+            p${j}.and(p${i});
+    #end
+    #set ( $i = $i + 1 )
+  #end
+            if (toSaveKeyCriterion == null)
+            {
+                toSaveKeyCriterion = p0;
+            }
+            else
+            {
+                toSaveKeyCriterion.or(p0);
+            }
+        }
+        criteria.and(toSaveKeyCriterion);
+#end
+        List<${foreignDbObjectClassName}> intersection
+                = ${foreignTablePeerClassName}.doSelect(criteria, connection);
+        $fieldType linkedCache;
+        if (toLinkTo.${isInitialized}()) {
+            linkedCache = toLinkTo.${getter}();
+            linkedCache.clear();
+        }
+        else
+        {
+            linkedCache = toLinkTo.${initializer}();
+        }
+        for (${foreignDbObjectClassName} toSaveElement : toSave)
+        {
+            int listIndex = intersection.indexOf(toSaveElement);
+            if (listIndex == -1)
+            {
+                toLinkTo.${adder}(toSaveElement);
+#if ($saveMethodsInDbObjects != "true")
+                ${foreignTablePeerClassName}.save(toSaveElement, connection);
+#else
+                toSaveElement.save(connection);
+#end
+            }
+            else
+            {
+                toLinkTo.${adder}(toSaveElement);
+                if (!toSaveElement.valueEquals(intersection.get(listIndex)))
+                {
+                    //force saving if content differs
+                    toSaveElement.setModified(true);
+                }
+#if ($saveMethodsInDbObjects != "true")
+                ${foreignTablePeerClassName}.save(toSaveElement, connection);
+#else
+                toSaveElement.save(connection);
+#end
+            }
+            toSaveKeys.add(toSaveElement.getPrimaryKey());
+        }
+        
+        // delete elements not in intersection
+        Criteria deleteCriteria = new Criteria();
+        deleteCriteria.where(onlyReferencingCriterion);
+#if ($foreignPrimaryKeyColumnElements.size() == 1)
+  #set ( $columnElement = $foreignPrimaryKeyColumnElements.get(0) )
+  #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+        deleteCriteria.and(${foreignTablePeerClassName}.${peerColumnName}, toSaveKeys, Criteria.NOT_IN);
+#else
+        toSaveKeyCriterion = null;
+        for (ObjectKey toSaveKey : toSaveKeys)
+        {
+            SimpleKey[] toSavePrimaryKeys = (SimpleKey[]) toSaveKey.getValue();
+  #set ( $i = 0 )
+  #foreach ($columnElement in $foreignPrimaryKeyColumnElements)
+  #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column") )
+    #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
+             Criterion p$i = new Criterion(
+                     ${foreignTablePeerClassName}.${peerColumnName},
+                     toSavePrimaryKeys[$i],
+                     Criteria.NOT_EQUAL);
+    #set ( $j = $i - 1 )
+    #if ($i > 0)
+            p${j}.or(p${i});
+    #end
+    #set ( $i = $i + 1 )
+  #end
+            if (toSaveKeyCriterion == null)
+            {
+                toSaveKeyCriterion = p0;
+            }
+            else
+            {
+                toSaveKeyCriterion.and(p0);
+            }
+        }
+        deleteCriteria.and(toSaveKeyCriterion);
+#end
+        ${foreignTablePeerClassName}.doDelete(deleteCriteria, connection);
+    }
+#end

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/foreign-key-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/foreign-key-schema.xml?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/foreign-key-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/foreign-key-schema.xml Tue Nov 27 20:02:32 2012
@@ -155,6 +155,31 @@
     </foreign-key>
   </table>
 
+  <table name="COMP_PK_OTHER_FK" idMethod="none"
+      description="table with a composite primary key which does not contain 
+          the foreign key column which references the non-composite 
+          primary key of another table">
+    <column name="ID1" primaryKey="true" type="INTEGER" javaType="object"/>
+    <column name="ID2" primaryKey="true" type="VARCHAR" size="50"/>
+    <column name="FK" type="INTEGER" javaType="object"/>
+    <column name="NAME" type="VARCHAR" size="100"/>
+    <foreign-key foreignTable="O_INTEGER_PK">
+      <reference local="FK" foreign="ID"/>
+    </foreign-key>
+  </table>
+
+  <table name="COMP_PK_CONTAINS_FK" idMethod="none"
+      description="table with a composite primary key a part of which
+          is a foreign key column which references the non-composite 
+          primary key of another table">
+    <column name="ID1" primaryKey="true" type="INTEGER" javaType="object"/>
+    <column name="ID2" primaryKey="true" type="VARCHAR" size="50"/>
+    <column name="NAME" type="VARCHAR" size="100"/>
+    <foreign-key foreignTable="O_INTEGER_PK">
+      <reference local="ID1" foreign="ID"/>
+    </foreign-key>
+  </table>
+
   <table name="COMP_INTEGER_VARCHAR_PK" idMethod="none"
       description="table with a composite primary key consisting of an integer
           and a varchar column">

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java Tue Nov 27 20:02:32 2012
@@ -22,10 +22,15 @@ package org.apache.torque;
 import java.util.ArrayList;
 import java.util.List;
 
+import junit.framework.Assert;
+
 import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.mapper.IntegerMapper;
 import org.apache.torque.test.dbobject.CompIntegerVarcharFk;
 import org.apache.torque.test.dbobject.CompIntegerVarcharPk;
 import org.apache.torque.test.dbobject.CompNonpkFk;
+import org.apache.torque.test.dbobject.CompPkContainsFk;
+import org.apache.torque.test.dbobject.CompPkOtherFk;
 import org.apache.torque.test.dbobject.NonPkOIntegerFk;
 import org.apache.torque.test.dbobject.NonPkPIntegerFk;
 import org.apache.torque.test.dbobject.NullableOIntegerFk;
@@ -37,6 +42,8 @@ import org.apache.torque.test.dbobject.R
 import org.apache.torque.test.peer.CompIntegerVarcharFkPeer;
 import org.apache.torque.test.peer.CompIntegerVarcharPkPeer;
 import org.apache.torque.test.peer.CompNonpkFkPeer;
+import org.apache.torque.test.peer.CompPkContainsFkPeer;
+import org.apache.torque.test.peer.CompPkOtherFkPeer;
 import org.apache.torque.test.peer.NonPkOIntegerFkPeer;
 import org.apache.torque.test.peer.NonPkPIntegerFkPeer;
 import org.apache.torque.test.peer.NullableOIntegerFkPeer;
@@ -45,6 +52,7 @@ import org.apache.torque.test.peer.OInte
 import org.apache.torque.test.peer.PIntegerPkPeer;
 import org.apache.torque.test.peer.RequiredOIntegerFkPeer;
 import org.apache.torque.test.peer.RequiredPIntegerFkPeer;
+import org.apache.torque.util.functions.Count;
 
 /**
  * Contains data (i.e. table records) for the tables in the foreign key schema.
@@ -53,37 +61,43 @@ import org.apache.torque.test.peer.Requi
  */
 public class ForeignKeySchemaData
 {
-    private List<PIntegerPk> pIntegerPkList
+    private final List<PIntegerPk> pIntegerPkList
         = new ArrayList<PIntegerPk>();
 
-    private List<NullablePIntegerFk> nullablePIntegerFkList
+    private final List<NullablePIntegerFk> nullablePIntegerFkList
         = new ArrayList<NullablePIntegerFk>();
 
-    private List<RequiredPIntegerFk> requiredPIntegerFkList
+    private final List<RequiredPIntegerFk> requiredPIntegerFkList
         = new ArrayList<RequiredPIntegerFk>();
 
-    private List<NonPkPIntegerFk> nonPkPIntegerFkList
+    private final List<NonPkPIntegerFk> nonPkPIntegerFkList
         = new ArrayList<NonPkPIntegerFk>();
 
-    private List<OIntegerPk> oIntegerPkList
+    private final List<OIntegerPk> oIntegerPkList
         = new ArrayList<OIntegerPk>();
 
-    private List<NullableOIntegerFk> nullableOIntegerFkList
+    private final List<NullableOIntegerFk> nullableOIntegerFkList
         = new ArrayList<NullableOIntegerFk>();
 
-    private List<RequiredOIntegerFk> requiredOIntegerFkList
+    private final List<RequiredOIntegerFk> requiredOIntegerFkList
         = new ArrayList<RequiredOIntegerFk>();
 
-    private List<NonPkOIntegerFk> nonPkOIntegerFkList
+    private final List<NonPkOIntegerFk> nonPkOIntegerFkList
         = new ArrayList<NonPkOIntegerFk>();
 
-    private List<CompIntegerVarcharPk> compositeIntegerVarcharPkList
+    private final List<CompPkOtherFk> compositePkOtherFkList
+        = new ArrayList<CompPkOtherFk>();
+
+    private final List<CompPkContainsFk> compositePkContainsFkList
+        = new ArrayList<CompPkContainsFk>();
+
+    private final List<CompIntegerVarcharPk> compositeIntegerVarcharPkList
         = new ArrayList<CompIntegerVarcharPk>();
 
-    private List<CompIntegerVarcharFk> compositeIntegerVarcharFkList
+    private final List<CompIntegerVarcharFk> compositeIntegerVarcharFkList
     = new ArrayList<CompIntegerVarcharFk>();
 
-    private List<CompNonpkFk> compositeNonpkFkList
+    private final List<CompNonpkFk> compositeNonpkFkList
         = new ArrayList<CompNonpkFk>();
 
     /**
@@ -108,11 +122,14 @@ public class ForeignKeySchemaData
      * oIntegerPk1
      *     - nonPkOIntegerFk1a
      *     - nonPkOIntegerFk1b
+     *     - compositePkOtherFk1a
+     *     - compositePkOtherFk1b
      *
      * oIntegerPk2
      *     - nullableOIntegerFk2
      *     - requiredOIntegerFk2
      *     - nonPkOIntegerFk2
+     *     - compositePkOtherFk2
      *
      * oIntegerPk3
      *     - nullableOIntegerFk3a
@@ -122,18 +139,22 @@ public class ForeignKeySchemaData
      *
      * null
      *     - nullableOIntegerFk4
+     *     - nonPkOIntegerFk4
      *
      * compositeIntegerVarcharPk1
      *     - compositeNonpkFk1a
      *     - compositeNonpkFk1b
      *
      * compositeIntegerVarcharPk2
-     *     - compositeIntegerVarcharPk2
+     *     - compositeIntegerVarcharFk2
      *     - compositeNonpkFk2
      *
      * compositeIntegerVarcharPk3
-     *     - compositeIntegerVarcharPk3a
-     *     - compositeIntegerVarcharPk3b
+     *     - compositeIntegerVarcharFk3a
+     *     - compositeIntegerVarcharFk3b
+     *
+     * null
+     *     - compositeIntegerVarcharFk4
      *
      * @return a new instance filled with the default test data.
      *
@@ -153,6 +174,8 @@ public class ForeignKeySchemaData
         fillNullableOIntegerFks(result);
         fillRequiredOIntegerFks(result);
         fillNonPkOIntegerFks(result);
+        fillCompositePkOtherFks(result);
+        fillCompositePkContainsFks(result);
 
         fillCompositeIntegerVarcharPks(result);
         fillCompositeIntegerVarcharFks(result);
@@ -388,6 +411,85 @@ public class ForeignKeySchemaData
                 nonPkOIntegerFk2);
         result.getNonPkOIntegerFkList().add(
                 nonPkOIntegerFk2);
+
+        NonPkOIntegerFk nonPkOIntegerFk4
+                = new NonPkOIntegerFk();
+        nonPkOIntegerFk4.setName(
+                "nonPkOIntegerFk4");
+        result.getNonPkOIntegerFkList().add(
+                nonPkOIntegerFk4);
+    }
+
+    private static void fillCompositePkOtherFks(ForeignKeySchemaData result)
+            throws TorqueException
+    {
+        CompPkOtherFk compositePkOtherFk1a
+                = new CompPkOtherFk();
+        compositePkOtherFk1a.setName(
+                "compositePkOtherFk1a");
+        compositePkOtherFk1a.setId1(1);
+        compositePkOtherFk1a.setId2("1a");
+        result.getOIntegerPkList().get(0).addCompPkOtherFk(
+                compositePkOtherFk1a);
+        result.getCompositePkOtherFkList().add(
+                compositePkOtherFk1a);
+
+        CompPkOtherFk compositePkOtherFk1b
+                = new CompPkOtherFk();
+        compositePkOtherFk1b.setName(
+                "compositePkOtherFk1b");
+        compositePkOtherFk1b.setId1(1);
+        compositePkOtherFk1b.setId2("1b");
+        result.getOIntegerPkList().get(0).addCompPkOtherFk(
+                compositePkOtherFk1b);
+        result.getCompositePkOtherFkList().add(
+                compositePkOtherFk1b);
+
+        CompPkOtherFk compositePkOtherFk2
+                = new CompPkOtherFk();
+        compositePkOtherFk2.setName(
+                "compositePkOtherFk22");
+        compositePkOtherFk2.setId1(2);
+        compositePkOtherFk2.setId2("2");
+        result.getOIntegerPkList().get(1).addCompPkOtherFk(
+                compositePkOtherFk2);
+        result.getCompositePkOtherFkList().add(
+                compositePkOtherFk2);
+    }
+
+    private static void fillCompositePkContainsFks(ForeignKeySchemaData result)
+            throws TorqueException
+    {
+        CompPkContainsFk compositePkContainsFk1a
+                = new CompPkContainsFk();
+        compositePkContainsFk1a.setName(
+                "compositePkContainsFk1a");
+        compositePkContainsFk1a.setId2("1a");
+        result.getOIntegerPkList().get(0).addCompPkContainsFk(
+                compositePkContainsFk1a);
+        result.getCompositePkContainsFkList().add(
+                compositePkContainsFk1a);
+
+        CompPkContainsFk compositePkContainsFk1b
+                = new CompPkContainsFk();
+        compositePkContainsFk1b.setName(
+                "compositePkOtherFk1b");
+        compositePkContainsFk1b.setId2("1b");
+        result.getOIntegerPkList().get(0).addCompPkContainsFk(
+                compositePkContainsFk1b);
+        result.getCompositePkContainsFkList().add(
+                compositePkContainsFk1b);
+
+        CompPkContainsFk compositePkContainsFk2
+                = new CompPkContainsFk();
+        compositePkContainsFk2.setName(
+                "compositePkOtherFk22");
+        compositePkContainsFk2.setId1(2);
+        compositePkContainsFk2.setId2("2");
+        result.getOIntegerPkList().get(1).addCompPkContainsFk(
+                compositePkContainsFk2);
+        result.getCompositePkContainsFkList().add(
+                compositePkContainsFk2);
     }
 
     private static void fillCompositeIntegerVarcharPks(
@@ -457,6 +559,13 @@ public class ForeignKeySchemaData
                     compositeIntegerVarcharFk3b);
         result.getCompositeIntegerVarcharFkList().add(
                 compositeIntegerVarcharFk3b);
+
+        CompIntegerVarcharFk compositeIntegerVarcharFk4
+                = new CompIntegerVarcharFk();
+        compositeIntegerVarcharFk4.setName(
+                "compositeIntegerVarcharFk4");
+        result.getCompositeIntegerVarcharFkList().add(
+                compositeIntegerVarcharFk4);
     }
 
     private static void fillCompositeNonpkFks(
@@ -529,6 +638,16 @@ public class ForeignKeySchemaData
         return nonPkOIntegerFkList;
     }
 
+    public List<CompPkOtherFk> getCompositePkOtherFkList()
+    {
+        return compositePkOtherFkList;
+    }
+
+    public List<CompPkContainsFk> getCompositePkContainsFkList()
+    {
+        return compositePkContainsFkList;
+    }
+
     public List<CompIntegerVarcharPk> getCompositeIntegerVarcharPkList()
     {
         return compositeIntegerVarcharPkList;
@@ -556,15 +675,32 @@ public class ForeignKeySchemaData
         {
             pIntegerPk.save();
         }
+        for (NullablePIntegerFk nullablePIntegerFk : nullablePIntegerFkList)
+        {
+            nullablePIntegerFk.save();
+        }
         for (OIntegerPk oIntegerPk : oIntegerPkList)
         {
             oIntegerPk.save();
         }
+        for (NullableOIntegerFk nullableOIntegerFk : nullableOIntegerFkList)
+        {
+            nullableOIntegerFk.save();
+        }
+        for (NonPkOIntegerFk nonPkOIntegerFk : nonPkOIntegerFkList)
+        {
+            nonPkOIntegerFk.save();
+        }
         for (CompIntegerVarcharPk compositeIntegerVarcharPk
                 : compositeIntegerVarcharPkList)
         {
             compositeIntegerVarcharPk.save();
         }
+        for (CompIntegerVarcharFk compositeIntegerVarcharFk
+                : compositeIntegerVarcharFkList)
+        {
+            compositeIntegerVarcharFk.save();
+        }
     }
 
     /**
@@ -574,38 +710,21 @@ public class ForeignKeySchemaData
      */
     public static void clearTablesInDatabase() throws TorqueException
     {
-        Criteria criteria = new Criteria();
-        NullablePIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        RequiredPIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        NonPkPIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        NullableOIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        RequiredOIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        NonPkOIntegerFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        PIntegerPkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        OIntegerPkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        CompIntegerVarcharFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        CompNonpkFkPeer.doDelete(criteria);
-
-        criteria = new Criteria();
-        CompIntegerVarcharPkPeer.doDelete(criteria);
+        NullablePIntegerFkPeer.doDelete(new Criteria());
+        RequiredPIntegerFkPeer.doDelete(new Criteria());
+        NonPkPIntegerFkPeer.doDelete(new Criteria());
+        NullableOIntegerFkPeer.doDelete(new Criteria());
+        RequiredOIntegerFkPeer.doDelete(new Criteria());
+        NonPkOIntegerFkPeer.doDelete(new Criteria());
+        CompPkOtherFkPeer.doDelete(new Criteria());
+        CompPkContainsFkPeer.doDelete(new Criteria());
+
+        PIntegerPkPeer.doDelete(new Criteria());
+        OIntegerPkPeer.doDelete(new Criteria());
+
+        CompIntegerVarcharFkPeer.doDelete(new Criteria());
+        CompNonpkFkPeer.doDelete(new Criteria());
+        CompIntegerVarcharPkPeer.doDelete(new Criteria());
     }
 
     /**
@@ -714,4 +833,145 @@ public class ForeignKeySchemaData
             System.out.println(nullablePIntegerFks);
         }
     }
+
+    /**
+     * Checks that the table Non_Pk_O_Integer_Fk in the database
+     * contains only the passed objects.
+     *
+     * @param expected the expected content of the table, not null.
+     *
+     * * @throws TorqueException if accessing the database fails.
+     */
+    public static void assertNonPkOIntegerFksInDatabaseEquals(
+                List<NonPkOIntegerFk> expected)
+            throws TorqueException
+    {
+        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
+        Assert.assertEquals(new Integer(expected.size()),
+                NonPkOIntegerFkPeer.doSelectSingleRecord(
+                criteria, new IntegerMapper()));
+        for (NonPkOIntegerFk nonPkOIntegerFk : expected)
+        {
+            criteria = NonPkOIntegerFkPeer.buildCriteria(nonPkOIntegerFk);
+            criteria.addSelectColumn(new Count("*"));
+            Assert.assertEquals(
+                    "Expected but not found : " + nonPkOIntegerFk,
+                    new Integer(1),
+                    NonPkOIntegerFkPeer.doSelectSingleRecord(
+                            criteria, new IntegerMapper()));
+        }
+    }
+
+    /**
+     * Checks that the table Comp_O_Integer_Fk in the database
+     * contains only the passed objects.
+     *
+     * @param expected the expected content of the table, not null.
+     *
+     * * @throws TorqueException if accessing the database fails.
+     */
+    public static void assertCompositeIntegerVarcharFksInDatabaseEquals(
+                List<CompIntegerVarcharFk> expected)
+            throws TorqueException
+    {
+        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
+        Assert.assertEquals(new Integer(expected.size()),
+                CompIntegerVarcharFkPeer.doSelectSingleRecord(
+                criteria, new IntegerMapper()));
+        for (CompIntegerVarcharFk compIntegerVarcharFk : expected)
+        {
+            criteria = CompIntegerVarcharFkPeer.buildCriteria(
+                    compIntegerVarcharFk);
+            criteria.addSelectColumn(new Count("*"));
+            Assert.assertEquals(
+                    "Expected but not found : " + compIntegerVarcharFk,
+                    new Integer(1),
+                    CompIntegerVarcharFkPeer.doSelectSingleRecord(
+                            criteria, new IntegerMapper()));
+        }
+    }
+
+    /**
+     * Checks that the table Nullable_O_Integer_Fk in the database
+     * contains only the passed objects.
+     *
+     * @param expected the expected content of the table, not null.
+     *
+     * * @throws TorqueException if accessing the database fails.
+     */
+    public static void assertNullableOIntegerFksInDatabaseEquals(
+                List<NullableOIntegerFk> expected)
+            throws TorqueException
+    {
+        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
+        Assert.assertEquals(new Integer(expected.size()),
+                NullableOIntegerFkPeer.doSelectSingleRecord(
+                criteria, new IntegerMapper()));
+        for (NullableOIntegerFk nullableOIntegerFk : expected)
+        {
+            criteria = NullableOIntegerFkPeer.buildCriteria(nullableOIntegerFk);
+            criteria.addSelectColumn(new Count("*"));
+            Assert.assertEquals(
+                    "Expected but not found : " + nullableOIntegerFk,
+                    new Integer(1),
+                    NullableOIntegerFkPeer.doSelectSingleRecord(
+                            criteria, new IntegerMapper()));
+        }
+    }
+
+    /**
+     * Checks that the table Comp_Pk_Other_Fk in the database
+     * contains only the passed objects.
+     *
+     * @param expected the expected content of the table, not null.
+     *
+     * * @throws TorqueException if accessing the database fails.
+     */
+    public static void assertCompositePkOtherFksInDatabaseEquals(
+                List<CompPkOtherFk> expected)
+            throws TorqueException
+    {
+        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
+        Assert.assertEquals(new Integer(expected.size()),
+                CompPkOtherFkPeer.doSelectSingleRecord(
+                criteria, new IntegerMapper()));
+        for (CompPkOtherFk compPkOtherFk : expected)
+        {
+            criteria = CompPkOtherFkPeer.buildCriteria(compPkOtherFk);
+            criteria.addSelectColumn(new Count("*"));
+            Assert.assertEquals(
+                    "Expected but not found : " + compPkOtherFk,
+                    new Integer(1),
+                    CompPkOtherFkPeer.doSelectSingleRecord(
+                            criteria, new IntegerMapper()));
+        }
+    }
+
+    /**
+     * Checks that the table Comp_Pk_Contains_Fk in the database
+     * contains only the passed objects.
+     *
+     * @param expected the expected content of the table, not null.
+     *
+     * * @throws TorqueException if accessing the database fails.
+     */
+    public static void assertCompositePkContainsFksInDatabaseEquals(
+                List<CompPkContainsFk> expected)
+            throws TorqueException
+    {
+        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
+        Assert.assertEquals(new Integer(expected.size()),
+                CompPkContainsFkPeer.doSelectSingleRecord(
+                criteria, new IntegerMapper()));
+        for (CompPkContainsFk compPkContainsFk : expected)
+        {
+            criteria = CompPkContainsFkPeer.buildCriteria(compPkContainsFk);
+            criteria.addSelectColumn(new Count("*"));
+            Assert.assertEquals(
+                    "Expected but not found : " + compPkContainsFk,
+                    new Integer(1),
+                    CompPkContainsFkPeer.doSelectSingleRecord(
+                            criteria, new IntegerMapper()));
+        }
+    }
 }

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java?rev=1414363&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java Tue Nov 27 20:02:32 2012
@@ -0,0 +1,146 @@
+package org.apache.torque.generated.dataobject;
+
+/*
+ * 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.
+ */
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.test.dbobject.Book;
+
+/**
+ * Tests the valueEquals method in the data object classes.
+ *
+ * @version $Id$
+ */
+public class ValueEqualsTest extends BaseDatabaseTestCase
+{
+    /**
+     * Checks the valueEquals method outcome if all colums are not-null
+     * and equal in the two objects.
+     */
+    public void testAllSetAndEqual()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(1);
+        book1.setBookId(5);
+        book1.setIsbn("abc");
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(5);
+        book2.setIsbn("abc");
+        book2.setTitle("title");
+        assertTrue(book1.valueEquals(book2));
+    }
+
+    /**
+     * Checks the valueEquals method outcome if all colums are not-null
+     * and equal in the two objects except the primary key column.
+     */
+    public void testAllSetDifferentPk()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(1);
+        book1.setBookId(5);
+        book1.setIsbn("abc");
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(7);
+        book2.setIsbn("abc");
+        book2.setTitle("title");
+        assertFalse(book1.valueEquals(book2));
+    }
+
+    /**
+     * Checks the valueEquals method outcome if all colums are not-null
+     * and equal in the two objects except a non-primary key column.
+     */
+    public void testAllSetDifferentNonPk()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(1);
+        book1.setBookId(5);
+        book1.setIsbn("abc");
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(5);
+        book2.setIsbn("abc");
+        book2.setTitle("otherTitle");
+        assertFalse(book1.valueEquals(book2));
+    }
+
+    /**
+     * Checks the valueEquals method outcome if all colums are not-null
+     * and equal in the two objects except a non-primary-key foreign-key column.
+     */
+    public void testAllSetDifferentNonPkFk()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(3);
+        book1.setBookId(5);
+        book1.setIsbn("abc");
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(5);
+        book2.setIsbn("abc");
+        book2.setTitle("title");
+        assertFalse(book1.valueEquals(book2));
+    }
+
+    /**
+     * Checks the valueEquals method outcome if a column is null
+     * in the two objects and all other fields are set and equal.
+     */
+    public void testFieldNotSetBothNull()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(1);
+        book1.setBookId(5);
+        book1.setIsbn(null);
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(5);
+        book2.setIsbn(null);
+        book2.setTitle("title");
+        assertTrue(book1.valueEquals(book2));
+    }
+
+
+    /**
+     * Checks the valueEquals method outcome if a column is null
+     * in only one the two objects and all other fields are set and equal.
+     */
+    public void testFieldNotSetOneNull()
+    {
+        Book book1 = new Book();
+        book1.setAuthorId(1);
+        book1.setBookId(5);
+        book1.setIsbn(null);
+        book1.setTitle("title");
+        Book book2 = new Book();
+        book2.setAuthorId(1);
+        book2.setBookId(5);
+        book2.setIsbn("abc");
+        book2.setTitle("Title");
+        assertFalse(book1.valueEquals(book2));
+    }
+}

Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ValueEqualsTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java Tue Nov 27 20:02:32 2012
@@ -65,10 +65,10 @@ public class DeleteTest extends BaseData
             = testData.getNullableOIntegerFkList().get(0);
         int preDeleteId = toDelete.getId();
 
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertTrue(nullableOIntegerFkList.contains(toDelete));
 
         // call delete method and check result.
@@ -76,10 +76,10 @@ public class DeleteTest extends BaseData
         assertEquals(1, deleted);
         assertEquals(preDeleteId, toDelete.getId().intValue());
 
-        // check that there are two entries remaining in the database
+        // check that there are three entries remaining in the database
         // and the toDelete object was deleted
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(2, nullableOIntegerFkList.size());
+        assertEquals(3, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete));
 
         // check that no associated object has been deleted
@@ -106,10 +106,10 @@ public class DeleteTest extends BaseData
         toDelete.setId(toDelete.getId() - 1);
         int preDeleteId = toDelete.getId();
 
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete));
 
         // call delete method and check result.
@@ -119,7 +119,7 @@ public class DeleteTest extends BaseData
 
         // check that all entries remain in the database
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
     }
 
     /**
@@ -143,10 +143,10 @@ public class DeleteTest extends BaseData
         // check that isDeleted() is false before deletion
         assertFalse(toDelete.isDeleted());
 
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertTrue(nullableOIntegerFkList.contains(toDelete));
 
         // call delete method and check result.
@@ -155,10 +155,10 @@ public class DeleteTest extends BaseData
         assertEquals(preDeleteId, toDelete.getId().intValue());
         assertTrue(toDelete.isDeleted());
 
-        // check that there are two entries remaining in the database
+        // check that there are three entries remaining in the database
         // and the toDelete object was deleted
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(2, nullableOIntegerFkList.size());
+        assertEquals(3, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete));
     }
 
@@ -259,10 +259,10 @@ public class DeleteTest extends BaseData
         // check that isDeleted() is false before deletion
         assertFalse(toDelete.get(0).isDeleted());
         assertFalse(toDelete.get(1).isDeleted());
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertTrue(nullableOIntegerFkList.contains(toDelete.get(0)));
         assertTrue(nullableOIntegerFkList.contains(toDelete.get(1)));
 
@@ -275,10 +275,10 @@ public class DeleteTest extends BaseData
         assertTrue(toDelete.get(0).isDeleted());
         assertTrue(toDelete.get(1).isDeleted());
 
-        // check that there is one entries remaining in the database
+        // check that there are two entries remaining in the database
         // and the objects contained in toDelete object were deleted
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(1, nullableOIntegerFkList.size());
+        assertEquals(2, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete.get(0)));
         assertFalse(nullableOIntegerFkList.contains(toDelete.get(1)));
 
@@ -311,11 +311,11 @@ public class DeleteTest extends BaseData
         // check that isDeleted() is false before deletion
         assertFalse(toDelete.get(0).isDeleted());
         assertFalse(toDelete.get(1).isDeleted());
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         // prior to deletion
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete.get(0)));
         assertTrue(nullableOIntegerFkList.contains(toDelete.get(1)));
 
@@ -327,9 +327,9 @@ public class DeleteTest extends BaseData
         assertTrue(toDelete.get(0).isDeleted());
         assertTrue(toDelete.get(1).isDeleted());
 
-        // check that two entries remain in the database
+        // check that three entries remain in the database
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(2, nullableOIntegerFkList.size());
+        assertEquals(3, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete.get(1)));
     }
 
@@ -349,10 +349,10 @@ public class DeleteTest extends BaseData
             = testData.getNullableOIntegerFkList().get(0);
         int preDeleteId = toDelete.getId();
 
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertTrue(nullableOIntegerFkList.contains(toDelete));
 
         // calculate and check primary key
@@ -365,10 +365,10 @@ public class DeleteTest extends BaseData
         assertEquals(1, deleted);
         assertEquals(preDeleteId, toDelete.getId().intValue());
 
-        // check that there are two entries remaining in the database
+        // check that there are three entries remaining in the database
         // and the toDelete object was deleted
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(2, nullableOIntegerFkList.size());
+        assertEquals(3, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete));
 
         // check that no associated object has been deleted
@@ -396,10 +396,10 @@ public class DeleteTest extends BaseData
         toDelete.setId(toDelete.getId() - 1);
         int preDeleteId = toDelete.getId();
 
-        // check that three entries are in the NullableOIntegerFk table
+        // check that four entries are in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
         assertFalse(nullableOIntegerFkList.contains(toDelete));
 
         // calculate and check primary key
@@ -414,7 +414,7 @@ public class DeleteTest extends BaseData
 
         // check that all entries remain in the database
         nullableOIntegerFkList = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
     }
 
     /**
@@ -438,11 +438,11 @@ public class DeleteTest extends BaseData
         int deletedCount = NullableOIntegerFkPeer.doDelete(criteria);
         assertEquals(2, deletedCount);
 
-        // check that only the last entry remains in the NullableOIntegerFk
-        // table
+        // check that only the last two entries remains
+        // in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(1, nullableOIntegerFkList.size());
+        assertEquals(2, nullableOIntegerFkList.size());
         assertEquals(
                 testData.getNullableOIntegerFkList().get(2).getId(),
                 nullableOIntegerFkList.get(0).getId());
@@ -474,7 +474,7 @@ public class DeleteTest extends BaseData
         // check that three entries remain in the NullableOIntegerFk table
         List<NullableOIntegerFk> nullableOIntegerFkList
                 = getNullableOIntegerFkList();
-        assertEquals(3, nullableOIntegerFkList.size());
+        assertEquals(4, nullableOIntegerFkList.size());
     }
 
     /**

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java?rev=1414363&r1=1414362&r2=1414363&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java Tue Nov 27 20:02:32 2012
@@ -54,7 +54,7 @@ import org.apache.torque.test.peer.Requi
 public class FillerTest extends BaseDatabaseTestCase
 {
     /** How many records are many records. */
-    private int MANY = 1256;
+    private final int MANY = 1256;
 
     /**
      * Tests the functionality for the fillers for referenced Objects.
@@ -151,7 +151,7 @@ public class FillerTest extends BaseData
                 NullableOIntegerFkPeer.ID);
         List<NullableOIntegerFk> fkList
                 = NullableOIntegerFkPeer.doSelect(criteria);
-        assertEquals(3, fkList.size());
+        assertEquals(4, fkList.size());
         assertEquals(
                 testData.getNullableOIntegerFkList().get(0).getId(),
                 fkList.get(0).getId());
@@ -225,7 +225,7 @@ public class FillerTest extends BaseData
                 NonPkOIntegerFkPeer.ID);
         List<NonPkOIntegerFk> fkList
                 = NonPkOIntegerFkPeer.doSelect(criteria);
-        assertEquals(3, fkList.size());
+        assertEquals(4, fkList.size());
         assertEquals(
                 testData.getNonPkOIntegerFkList().get(0).getId(),
                 fkList.get(0).getId());
@@ -394,7 +394,7 @@ public class FillerTest extends BaseData
                 CompIntegerVarcharFkPeer.ID);
         List<CompIntegerVarcharFk> fkList
                 = CompIntegerVarcharFkPeer.doSelect(criteria);
-        assertEquals(3, fkList.size());
+        assertEquals(4, fkList.size());
         assertEquals(
                 testData.getCompositeIntegerVarcharFkList().get(0).getId(),
                 fkList.get(0).getId());



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