db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1517385 - in /db/torque/torque4/trunk/torque-test: ./ src/main/schema/ src/test/java/org/apache/torque/ src/test/java/org/apache/torque/generated/dataobject/ src/test/java/org/apache/torque/generated/peer/
Date Sun, 25 Aug 2013 21:19:24 GMT
Author: tfischer
Date: Sun Aug 25 21:19:23 2013
New Revision: 1517385

URL: http://svn.apache.org/r1517385
Log:
TORQUE-293 add test cases

Added:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ForeignKeyJoinGetterTest.java
  (with props)
Modified:
    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/BaseDatabaseTestCase.java
    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/SetAndSaveTest.java
    db/torque/torque4/trunk/torque-test/torque-gen.properties

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=1517385&r1=1517384&r2=1517385&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 Sun Aug 25
21:19:23 2013
@@ -167,12 +167,11 @@
   </table>
 
   <table name="MULTI_REF_SAME_TABLE" 
-      description="Table to test multiple references to a same table"
-      idMethod="none">
+      description="Table to test multiple references to a same table">
     <column name="ID" primaryKey="true" type="INTEGER"/>
-    <column name="REFERENCE_1" type="INTEGER"/>
-    <column name="REFERENCE_2" type="INTEGER"/>
-    <column name="REFERENCE_3" type="INTEGER"/>
+    <column name="REFERENCE_1" type="INTEGER" javaType="object"/>
+    <column name="REFERENCE_2" type="INTEGER" javaType="object"/>
+    <column name="REFERENCE_3" type="INTEGER" javaType="object"/>
     <column name="NAME" type="VARCHAR" size="100"/>
     <foreign-key foreignTable="O_INTEGER_PK">
       <reference local="REFERENCE_1" foreign="ID"/>
@@ -186,12 +185,11 @@
   </table>
 
   <table name="MULTI_REF" 
-      description="Table to test multiple references to different tables"
-      idMethod="none">
+      description="Table to test multiple references to different tables">
     <column name="ID" primaryKey="true" type="INTEGER"/>
-    <column name="O_INTEGER_PK_ID" type="INTEGER"/>
-    <column name="P_INTEGER_PK_ID" type="INTEGER"/>
-    <column name="NULLABLE_O_INTEGER_FK_ID" type="INTEGER"/>
+    <column name="O_INTEGER_PK_ID" type="INTEGER" javaType="object"/>
+    <column name="P_INTEGER_PK_ID" type="INTEGER" javaType="object"/>
+    <column name="NULLABLE_O_INTEGER_FK_ID" type="INTEGER" javaType="object"/>
     <column name="NAME" type="VARCHAR" size="100"/>
     <foreign-key foreignTable="O_INTEGER_PK">
       <reference local="O_INTEGER_PK_ID" foreign="ID"/>

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java?rev=1517385&r1=1517384&r2=1517385&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
Sun Aug 25 21:19:23 2013
@@ -19,6 +19,8 @@ package org.apache.torque;
  * under the License.
  */
 
+import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -129,6 +131,28 @@ public abstract class BaseDatabaseTestCa
     }
 
     /**
+     * Queries the database for its major version.
+     *
+     * @param connection a connection to the database.
+     *
+     * @return the version String from the connection metadata
+     *
+     * @throws TorqueException if the query fails.
+     */
+    protected int getDatabaseMajorVersion(final Connection connection)
+            throws TorqueException
+    {
+        try
+        {
+            return connection.getMetaData().getDatabaseMajorVersion();
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
      * Deletes all authors and books in the bookstore tables.
      *
      * @throws TorqueException if the bookstore could not be cleaned

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=1517385&r1=1517384&r2=1517385&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
Sun Aug 25 21:19:23 2013
@@ -31,6 +31,8 @@ import org.apache.torque.test.dbobject.C
 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.MultiRef;
+import org.apache.torque.test.dbobject.MultiRefSameTable;
 import org.apache.torque.test.dbobject.NonPkOIntegerFk;
 import org.apache.torque.test.dbobject.NonPkPIntegerFk;
 import org.apache.torque.test.dbobject.NullableOIntegerFk;
@@ -102,6 +104,12 @@ public class ForeignKeySchemaData
     private final List<CompNonpkFk> compositeNonpkFkList
         = new ArrayList<CompNonpkFk>();
 
+    private final List<MultiRef> multiRefList
+        = new ArrayList<MultiRef>();
+
+    private final List<MultiRefSameTable> multiRefSameTableList
+        = new ArrayList<MultiRefSameTable>();
+
     /**
      * Creates the default Test data for the foreign key schema.
      * The test data is filled as follows (p=primitive, o=object):
@@ -109,11 +117,15 @@ public class ForeignKeySchemaData
      * pIntegerPk1
      *     - nonPkPIntegerFk1a
      *     - nonPkPIntegerFk1b
+     *     - multiRef111a
+     *     - multiRef111a
+     *     - multiRef010
      *
      * pIntegerPk2
      *     - nonPkPIntegerFk2
      *     - nullablePIntegerFk2
      *     - requiredPIntegerFk2
+     *     - multiRef222
      *
      * PIntegerPk3
      *     - nullablePIntegerFk3a
@@ -126,12 +138,16 @@ public class ForeignKeySchemaData
      *     - nonPkOIntegerFk1b
      *     - compositePkOtherFk1a
      *     - compositePkOtherFk1b
+     *     - multiRef111a
+     *     - multiRef111a
+     *     - multiRef100
      *
      * oIntegerPk2
      *     - nullableOIntegerFk2
      *     - requiredOIntegerFk2
      *     - nonPkOIntegerFk2
      *     - compositePkOtherFk2
+     *     - multiRef222
      *
      * oIntegerPk3
      *     - nullableOIntegerFk3a
@@ -155,6 +171,14 @@ public class ForeignKeySchemaData
      *     - compositeIntegerVarcharFk3a
      *     - compositeIntegerVarcharFk3b
      *
+     * nullableOIntegerFk1
+     *     - multiRef111a
+     *     - multiRef111a
+     *     - multiRef001
+     *
+     * nullableOIntegerFk2
+     *     - multiRef222
+     *
      * null
      *     - compositeIntegerVarcharFk4
      *
@@ -183,10 +207,13 @@ public class ForeignKeySchemaData
         fillCompositeIntegerVarcharFks(result);
         fillCompositeNonpkFks(result);
 
+        fillMultiRefs(result);
+        fillMultiRefSameTables(result);
+
         return result;
     }
 
-    private static void fillPIntegerPks(ForeignKeySchemaData result)
+    private static void fillPIntegerPks(final ForeignKeySchemaData result)
     {
         PIntegerPk pIntegerPk1 = new PIntegerPk();
         pIntegerPk1.setName("pIntegerPk1");
@@ -204,7 +231,7 @@ public class ForeignKeySchemaData
         result.getPIntegerPkList().add(pIntegerPk3);
     }
 
-    private static void fillNullablePIntegerPks(ForeignKeySchemaData result)
+    private static void fillNullablePIntegerPks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         NullablePIntegerFk nullablePIntegerFk2
@@ -235,7 +262,7 @@ public class ForeignKeySchemaData
                 nullablePIntegerFk3b);
     }
 
-    private static void fillRequiredPIntegerFks(ForeignKeySchemaData result)
+    private static void fillRequiredPIntegerFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         RequiredPIntegerFk requiredPIntegerFk2
@@ -266,7 +293,7 @@ public class ForeignKeySchemaData
                 requiredPIntegerFk3b);
     }
 
-    private static void fillNonPkIntegerFks(ForeignKeySchemaData result)
+    private static void fillNonPkIntegerFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         NonPkPIntegerFk nonPkPIntegerFk1a
@@ -297,7 +324,7 @@ public class ForeignKeySchemaData
                 nonPkPIntegerFk2);
     }
 
-    private static void fillOIntegerPks(ForeignKeySchemaData result)
+    private static void fillOIntegerPks(final ForeignKeySchemaData result)
     {
         OIntegerPk oIntegerPk1 = new OIntegerPk();
         oIntegerPk1.setName("oIntegerPk1");
@@ -315,7 +342,7 @@ public class ForeignKeySchemaData
         result.getOIntegerPkList().add(oIntegerPk3);
     }
 
-    private static void fillNullableOIntegerFks(ForeignKeySchemaData result)
+    private static void fillNullableOIntegerFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         NullableOIntegerFk nullableOIntegerFk2
@@ -353,7 +380,7 @@ public class ForeignKeySchemaData
                 nullableOIntegerFk4);
     }
 
-    private static void fillRequiredOIntegerFks(ForeignKeySchemaData result)
+    private static void fillRequiredOIntegerFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         RequiredOIntegerFk requiredOIntegerFk2
@@ -384,7 +411,7 @@ public class ForeignKeySchemaData
                 requiredOIntegerFk3b);
     }
 
-    private static void fillNonPkOIntegerFks(ForeignKeySchemaData result)
+    private static void fillNonPkOIntegerFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         NonPkOIntegerFk nonPkOIntegerFk1a
@@ -422,7 +449,7 @@ public class ForeignKeySchemaData
                 nonPkOIntegerFk4);
     }
 
-    private static void fillCompositePkOtherFks(ForeignKeySchemaData result)
+    private static void fillCompositePkOtherFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         CompPkOtherFk compositePkOtherFk1a
@@ -459,7 +486,7 @@ public class ForeignKeySchemaData
                 compositePkOtherFk2);
     }
 
-    private static void fillCompositePkContainsFks(ForeignKeySchemaData result)
+    private static void fillCompositePkContainsFks(final ForeignKeySchemaData result)
             throws TorqueException
     {
         CompPkContainsFk compositePkContainsFk1a
@@ -495,7 +522,7 @@ public class ForeignKeySchemaData
     }
 
     private static void fillCompositeIntegerVarcharPks(
-            ForeignKeySchemaData result)
+            final ForeignKeySchemaData result)
     {
         CompIntegerVarcharPk compositeIntegerVarcharPk1
                 = new CompIntegerVarcharPk();
@@ -529,7 +556,7 @@ public class ForeignKeySchemaData
     }
 
     private static void fillCompositeIntegerVarcharFks(
-                ForeignKeySchemaData result)
+                final ForeignKeySchemaData result)
             throws TorqueException
     {
         CompIntegerVarcharFk compositeIntegerVarcharFk2
@@ -571,33 +598,187 @@ public class ForeignKeySchemaData
     }
 
     private static void fillCompositeNonpkFks(
-            ForeignKeySchemaData result)
-        throws TorqueException
-{
-    CompNonpkFk compositeNonpkFk1a
-            = new CompNonpkFk();
-    compositeNonpkFk1a.setName(
-            "compositeNonpkFk1a");
-    result.getCompositeIntegerVarcharPkList().get(0)
-            .addCompNonpkFk(compositeNonpkFk1a);
-    result.getCompositeNonpkFkList().add(compositeNonpkFk1a);
-
-    CompNonpkFk compositeNonpkFk1b
-            = new CompNonpkFk();
-    compositeNonpkFk1b.setName(
-            "compositeNonpkFk1b");
-    result.getCompositeIntegerVarcharPkList().get(0)
-            .addCompNonpkFk(compositeNonpkFk1b);
-    result.getCompositeNonpkFkList().add(compositeNonpkFk1b);
-
-    CompNonpkFk compositeNonpkFk2
-            = new CompNonpkFk();
-    compositeNonpkFk2.setName(
-            "compositeNonpkFk2");
-    result.getCompositeIntegerVarcharPkList().get(1)
-            .addCompNonpkFk(compositeNonpkFk2);
-    result.getCompositeNonpkFkList().add(compositeNonpkFk2);
-}
+                final ForeignKeySchemaData result)
+            throws TorqueException
+    {
+        CompNonpkFk compositeNonpkFk1a
+                = new CompNonpkFk();
+        compositeNonpkFk1a.setName(
+                "compositeNonpkFk1a");
+        result.getCompositeIntegerVarcharPkList().get(0)
+                .addCompNonpkFk(compositeNonpkFk1a);
+        result.getCompositeNonpkFkList().add(compositeNonpkFk1a);
+
+        CompNonpkFk compositeNonpkFk1b
+                = new CompNonpkFk();
+        compositeNonpkFk1b.setName(
+                "compositeNonpkFk1b");
+        result.getCompositeIntegerVarcharPkList().get(0)
+                .addCompNonpkFk(compositeNonpkFk1b);
+        result.getCompositeNonpkFkList().add(compositeNonpkFk1b);
+
+        CompNonpkFk compositeNonpkFk2
+                = new CompNonpkFk();
+        compositeNonpkFk2.setName(
+                "compositeNonpkFk2");
+        result.getCompositeIntegerVarcharPkList().get(1)
+                .addCompNonpkFk(compositeNonpkFk2);
+        result.getCompositeNonpkFkList().add(compositeNonpkFk2);
+    }
+
+    private static void fillMultiRefs(
+                final ForeignKeySchemaData result)
+            throws TorqueException
+    {
+        {
+            MultiRef multiRef111a = new MultiRef();
+            multiRef111a.setName("multiRef111a");
+            multiRef111a.setOIntegerPk(result.getOIntegerPkList().get(0));
+            multiRef111a.setPIntegerPk(result.getPIntegerPkList().get(0));
+            multiRef111a.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(0));
+            result.getMultiRefList().add(multiRef111a);
+        }
+
+        {
+            MultiRef multiRef111b = new MultiRef();
+            multiRef111b.setName("multiRef111b");
+            multiRef111b.setOIntegerPk(result.getOIntegerPkList().get(0));
+            multiRef111b.setPIntegerPk(result.getPIntegerPkList().get(0));
+            multiRef111b.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(0));
+            result.getMultiRefList().add(multiRef111b);
+        }
+
+        {
+            MultiRef multiRef100 = new MultiRef();
+            multiRef100.setName("multiRef100");
+            multiRef100.setOIntegerPk(result.getOIntegerPkList().get(0));
+            result.getMultiRefList().add(multiRef100);
+        }
+
+        {
+            MultiRef multiRef010 = new MultiRef();
+            multiRef010.setName("multiRef010");
+            multiRef010.setPIntegerPk(result.getPIntegerPkList().get(0));
+            result.getMultiRefList().add(multiRef010);
+        }
+
+        {
+            MultiRef multiRef001 = new MultiRef();
+            multiRef001.setName("multiRef001");
+            multiRef001.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(0));
+            result.getMultiRefList().add(multiRef001);
+        }
+
+        {
+            MultiRef multiRef120 = new MultiRef();
+            multiRef120.setName("multiRef120");
+            multiRef120.setOIntegerPk(result.getOIntegerPkList().get(0));
+            multiRef120.setPIntegerPk(result.getPIntegerPkList().get(1));
+            result.getMultiRefList().add(multiRef120);
+        }
+
+        {
+            MultiRef multiRef201 = new MultiRef();
+            multiRef201.setName("multiRef201");
+            multiRef201.setOIntegerPk(result.getOIntegerPkList().get(1));
+            multiRef201.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(0));
+            result.getMultiRefList().add(multiRef201);
+        }
+
+        {
+            MultiRef multiRef012 = new MultiRef();
+            multiRef012.setName("multiRef012");
+            multiRef012.setPIntegerPk(result.getPIntegerPkList().get(0));
+            multiRef012.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(1));
+            result.getMultiRefList().add(multiRef012);
+        }
+
+        {
+            MultiRef multiRef222 = new MultiRef();
+            multiRef222.setName("multiRef222");
+            multiRef222.setOIntegerPk(result.getOIntegerPkList().get(1));
+            multiRef222.setPIntegerPk(result.getPIntegerPkList().get(1));
+            multiRef222.setNullableOIntegerFk(result.getNullableOIntegerFkList().get(1));
+            result.getMultiRefList().add(multiRef222);
+        }
+    }
+
+    private static void fillMultiRefSameTables(
+                final ForeignKeySchemaData result)
+            throws TorqueException
+    {
+        {
+            MultiRefSameTable multiRefSameTable111a = new MultiRefSameTable();
+            multiRefSameTable111a.setName("multiRefSameTable111a");
+            multiRefSameTable111a.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(0));
+            multiRefSameTable111a.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(0));
+            multiRefSameTable111a.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable111a);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable111b = new MultiRefSameTable();
+            multiRefSameTable111b.setName("multiRefSameTable111b");
+            multiRefSameTable111b.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(0));
+            multiRefSameTable111b.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(0));
+            multiRefSameTable111b.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable111b);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable100 = new MultiRefSameTable();
+            multiRefSameTable100.setName("multiRefSameTable100");
+            multiRefSameTable100.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable100);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable010 = new MultiRefSameTable();
+            multiRefSameTable010.setName("multiRefSameTable010");
+            multiRefSameTable010.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable010);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable001 = new MultiRefSameTable();
+            multiRefSameTable001.setName("multiRefSameTable001");
+            multiRefSameTable001.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable001);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable120 = new MultiRefSameTable();
+            multiRefSameTable120.setName("multiRefSameTable120");
+            multiRefSameTable120.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(0));
+            multiRefSameTable120.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(1));
+            result.getMultiRefSameTableList().add(multiRefSameTable120);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable201 = new MultiRefSameTable();
+            multiRefSameTable201.setName("multiRefSameTable201");
+            multiRefSameTable201.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(1));
+            multiRefSameTable201.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(0));
+            result.getMultiRefSameTableList().add(multiRefSameTable201);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable012 = new MultiRefSameTable();
+            multiRefSameTable012.setName("multiRefSameTable012");
+            multiRefSameTable012.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(0));
+            multiRefSameTable012.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(1));
+            result.getMultiRefSameTableList().add(multiRefSameTable012);
+        }
+
+        {
+            MultiRefSameTable multiRefSameTable222 = new MultiRefSameTable();
+            multiRefSameTable222.setName("multiRefSameTable222");
+            multiRefSameTable222.setOIntegerPkRelatedByReference1(result.getOIntegerPkList().get(1));
+            multiRefSameTable222.setOIntegerPkRelatedByReference2(result.getOIntegerPkList().get(1));
+            multiRefSameTable222.setOIntegerPkRelatedByReference3(result.getOIntegerPkList().get(1));
+            result.getMultiRefSameTableList().add(multiRefSameTable222);
+        }
+    }
 
     public List<PIntegerPk> getPIntegerPkList()
     {
@@ -665,6 +846,16 @@ public class ForeignKeySchemaData
         return compositeNonpkFkList;
     }
 
+    public List<MultiRef> getMultiRefList()
+    {
+        return multiRefList;
+    }
+
+    public List<MultiRefSameTable> getMultiRefSameTableList()
+    {
+        return multiRefSameTableList;
+    }
+
     /**
      * Saves all contained data if the data is new or was changed
      * after the last save.
@@ -703,6 +894,25 @@ public class ForeignKeySchemaData
         {
             compositeIntegerVarcharFk.save();
         }
+        for (MultiRef multiRef : multiRefList)
+        {
+            // refresh ids
+            multiRef.setOIntegerPk(multiRef.getOIntegerPk());
+            multiRef.setPIntegerPk(multiRef.getPIntegerPk());
+            multiRef.setNullableOIntegerFk(multiRef.getNullableOIntegerFk());
+            multiRef.save();
+        }
+        for (MultiRefSameTable multiRefSameTable : multiRefSameTableList)
+        {
+            // refresh ids
+            multiRefSameTable.setOIntegerPkRelatedByReference1(
+                    multiRefSameTable.getOIntegerPkRelatedByReference1());
+            multiRefSameTable.setOIntegerPkRelatedByReference2(
+                    multiRefSameTable.getOIntegerPkRelatedByReference2());
+            multiRefSameTable.setOIntegerPkRelatedByReference3(
+                    multiRefSameTable.getOIntegerPkRelatedByReference3());
+            multiRefSameTable.save();
+        }
     }
 
     /**
@@ -847,7 +1057,7 @@ public class ForeignKeySchemaData
      * * @throws TorqueException if accessing the database fails.
      */
     public static void assertNonPkOIntegerFksInDatabaseEquals(
-                List<NonPkOIntegerFk> expected)
+                final List<NonPkOIntegerFk> expected)
             throws TorqueException
     {
         Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
@@ -875,7 +1085,7 @@ public class ForeignKeySchemaData
      * * @throws TorqueException if accessing the database fails.
      */
     public static void assertCompositeIntegerVarcharFksInDatabaseEquals(
-                List<CompIntegerVarcharFk> expected)
+                final List<CompIntegerVarcharFk> expected)
             throws TorqueException
     {
         Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
@@ -904,7 +1114,7 @@ public class ForeignKeySchemaData
      * * @throws TorqueException if accessing the database fails.
      */
     public static void assertNullableOIntegerFksInDatabaseEquals(
-                List<NullableOIntegerFk> expected)
+                final List<NullableOIntegerFk> expected)
             throws TorqueException
     {
         Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
@@ -932,7 +1142,7 @@ public class ForeignKeySchemaData
      * * @throws TorqueException if accessing the database fails.
      */
     public static void assertCompositePkOtherFksInDatabaseEquals(
-                List<CompPkOtherFk> expected)
+                final List<CompPkOtherFk> expected)
             throws TorqueException
     {
         Criteria criteria = new Criteria().addSelectColumn(new Count("*"));
@@ -960,7 +1170,7 @@ public class ForeignKeySchemaData
      * * @throws TorqueException if accessing the database fails.
      */
     public static void assertCompositePkContainsFksInDatabaseEquals(
-                List<CompPkContainsFk> expected)
+                final List<CompPkContainsFk> expected)
             throws TorqueException
     {
         Criteria criteria = new Criteria().addSelectColumn(new Count("*"));

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ForeignKeyJoinGetterTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ForeignKeyJoinGetterTest.java?rev=1517385&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ForeignKeyJoinGetterTest.java
(added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/dataobject/ForeignKeyJoinGetterTest.java
Sun Aug 25 21:19:23 2013
@@ -0,0 +1,154 @@
+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 java.util.List;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.ForeignKeySchemaData;
+import org.apache.torque.Torque;
+import org.apache.torque.adapter.Adapter;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.test.dbobject.MultiRef;
+import org.apache.torque.test.dbobject.MultiRefSameTable;
+import org.apache.torque.test.dbobject.OIntegerPk;
+import org.apache.torque.test.peer.MultiRefPeer;
+import org.apache.torque.test.peer.MultiRefSameTablePeer;
+
+/**
+ * Tests the foreign key join getter methods in the generated
+ * data object classes.
+ *
+ * @version $Id$
+ */
+public class ForeignKeyJoinGetterTest extends BaseDatabaseTestCase
+{
+    ForeignKeySchemaData testData;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        ForeignKeySchemaData.clearTablesInDatabase();
+        testData = ForeignKeySchemaData.getDefaultTestData();
+        testData.save();
+    }
+
+    /**
+     * Checks that the test principle for switching silent db fetch works.
+     */
+    public void testSwitchSilentFetchingOff() throws Exception
+    {
+        OIntegerPk baseObject = testData.getOIntegerPkList().get(0);
+        List<MultiRef> multiRefs
+            = baseObject.getMultiRefs();
+        // switch silent fetching off
+        Adapter adapter = Torque.getOrCreateDatabase(Torque.getDefaultDB()).getAdapter();
+        try
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(null);
+            try
+            {
+                multiRefs.get(0).getPIntegerPk();
+                fail("Exception excpected");
+            }
+            catch (Exception e)
+            {
+                // expected
+            }
+        }
+        finally
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(adapter);
+        }
+    }
+
+    /**
+     * Checks that the joinGetter works if different tables are joined.
+     *
+     * @throws Exception if the database fails
+     */
+    public void testJoinGetter() throws Exception
+    {
+        OIntegerPk baseObject = testData.getOIntegerPkList().get(0);
+        List<MultiRef> multiRefs
+            = baseObject.getMultiRefsJoinPIntegerPk(
+                    new Criteria().addAscendingOrderByColumn(MultiRefPeer.ID));
+        assertEquals(3, multiRefs.size());
+        assertEquals("multiRef111a", multiRefs.get(0).getName());
+        assertEquals("multiRef111b", multiRefs.get(1).getName());
+        assertEquals("multiRef120", multiRefs.get(2).getName());
+        // switch silent fetching off
+        Adapter adapter = Torque.getOrCreateDatabase(Torque.getDefaultDB()).getAdapter();
+        try
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(null);
+            assertEquals(
+                    testData.getPIntegerPkList().get(0),
+                    multiRefs.get(0).getPIntegerPk());
+            assertEquals(
+                    testData.getPIntegerPkList().get(0),
+                    multiRefs.get(1).getPIntegerPk());
+            assertEquals(
+                    testData.getPIntegerPkList().get(1),
+                    multiRefs.get(2).getPIntegerPk());
+        }
+        finally
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(adapter);
+        }
+    }
+
+    /**
+     * Checks that the joinGetter works if same tables are joined.
+     *
+     * @throws Exception if the database fails
+     */
+    public void testJoinGetterSameObject() throws Exception
+    {
+        OIntegerPk baseObject = testData.getOIntegerPkList().get(0);
+        List<MultiRefSameTable> multiRefSameTables
+            = baseObject.getMultiRefSameTableRelatedByReference1sJoinOIntegerPkRelatedByReference2(
+                    new Criteria().addAscendingOrderByColumn(MultiRefSameTablePeer.ID));
+        assertEquals(3, multiRefSameTables.size());
+        assertEquals("multiRefSameTable111a", multiRefSameTables.get(0).getName());
+        assertEquals("multiRefSameTable111b", multiRefSameTables.get(1).getName());
+        assertEquals("multiRefSameTable120", multiRefSameTables.get(2).getName());
+        // switch silent fetching off
+        Adapter adapter = Torque.getOrCreateDatabase(Torque.getDefaultDB()).getAdapter();
+        try
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(null);
+            assertEquals(
+                    testData.getOIntegerPkList().get(0),
+                    multiRefSameTables.get(0).getOIntegerPkRelatedByReference2());
+            assertEquals(
+                    testData.getOIntegerPkList().get(0),
+                    multiRefSameTables.get(1).getOIntegerPkRelatedByReference2());
+            assertEquals(
+                    testData.getOIntegerPkList().get(1),
+                    multiRefSameTables.get(2).getOIntegerPkRelatedByReference2());
+        }
+        finally
+        {
+            Torque.getOrCreateDatabase(Torque.getDefaultDB()).setAdapter(adapter);
+        }
+    }
+}

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

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=1517385&r1=1517384&r2=1517385&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
Sun Aug 25 21:19:23 2013
@@ -59,6 +59,8 @@ public class DeleteTest extends BaseData
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         NullableOIntegerFk toDelete
@@ -133,6 +135,8 @@ public class DeleteTest extends BaseData
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         NullableOIntegerFk toDelete
@@ -246,6 +250,8 @@ public class DeleteTest extends BaseData
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         List<NullableOIntegerFk> toDelete
@@ -343,6 +349,8 @@ public class DeleteTest extends BaseData
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         NullableOIntegerFk toDelete
@@ -427,6 +435,8 @@ public class DeleteTest extends BaseData
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         // call delete method

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java?rev=1517385&r1=1517384&r2=1517385&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java
Sun Aug 25 21:19:23 2013
@@ -517,6 +517,8 @@ public class SetAndSaveTest extends Base
         ForeignKeySchemaData.clearTablesInDatabase();
         ForeignKeySchemaData testData
                 = ForeignKeySchemaData.getDefaultTestData();
+        // we want to avoid fk errors in MultiRef
+        testData.getMultiRefList().clear();
         testData.save();
 
         OIntegerPk oIntegerPk = testData.getOIntegerPkList().get(2);

Modified: db/torque/torque4/trunk/torque-test/torque-gen.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/torque-gen.properties?rev=1517385&r1=1517384&r2=1517385&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/torque-gen.properties (original)
+++ db/torque/torque4/trunk/torque-test/torque-gen.properties Sun Aug 25 21:19:23 2013
@@ -24,6 +24,7 @@ torque.om.package=org.apache.torque.test
 
 torque.om.complexObjectModel.generateFillers=true
 torque.om.generateMapInit=true
+torque.om.complexObjectModel.joinGetterVisibility = public
 
 # package suffix for the data object classes
 torque.om.package.dbObjectPackageSuffix = .dbobject



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