db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1415341 - in /db/torque/torque4/trunk: torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm torque-test/src/test/java/org/apache/torque/generated/peer/SetAndSaveTest.java
Date Thu, 29 Nov 2012 19:52:04 GMT
Author: tfischer
Date: Thu Nov 29 19:52:03 2012
New Revision: 1415341

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

Modified:
    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/peer/SetAndSaveTest.java

Modified: 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=1415341&r1=1415340&r2=1415341&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setAndSaveReferencing.vm
Thu Nov 29 19:52:03 2012
@@ -235,11 +235,16 @@
             else
             {
                 toLinkTo.${adder}(toSaveElement);
+#if ($torqueGen.booleanOption("torque.om.trackNew"))
+                toSaveElement.setNew(false);
+#end
+#if ($torqueGen.booleanOption("torque.om.trackModified"))
                 if (!toSaveElement.valueEquals(intersection.get(listIndex)))
                 {
                     //force saving if content differs
                     toSaveElement.setModified(true);
                 }
+#end
 #if ($saveMethodsInDbObjects != "true")
                 ${foreignTablePeerClassName}.save(toSaveElement, connection);
 #else

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=1415341&r1=1415340&r2=1415341&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
Thu Nov 29 19:52:03 2012
@@ -441,10 +441,14 @@ public class SetAndSaveTest extends Base
 
         OIntegerPk oIntegerPk = testData.getOIntegerPkList().get(2);
         List<NullableOIntegerFk> fkList = new ArrayList<NullableOIntegerFk>();
-        // object already associated to this object
+        // copy object already associated to this object
         NullableOIntegerFk alreadyAssociated
-                = testData.getNullableOIntegerFkList().get(1);
-        alreadyAssociated.setName("modified");
+                = testData.getNullableOIntegerFkList().get(1).copy();
+        // id does not get copied, set manually
+        alreadyAssociated.setId(
+                testData.getNullableOIntegerFkList().get(1).getId());
+        alreadyAssociated.setName("modifiedName");
+        alreadyAssociated.setNew(true); // saving must also work with wrong new flag
         alreadyAssociated.setModified(false); // saving must work without the modified flag
         fkList.add(alreadyAssociated);
 
@@ -462,12 +466,17 @@ public class SetAndSaveTest extends Base
                 oIntegerPk.getId(),
                 cachedFks.get(0).getFk());
         assertEquals(
-                testData.getNullableOIntegerFkList().get(1).getName(),
+                "modifiedName",
                 cachedFks.get(0).getName());
 
         // check database
+        List<NullableOIntegerFk>expectedInDb
+                = new ArrayList<NullableOIntegerFk>();
+        expectedInDb.addAll(cachedFks);
+        expectedInDb.add(testData.getNullableOIntegerFkList().get(0));
+        expectedInDb.add(testData.getNullableOIntegerFkList().get(3));
         ForeignKeySchemaData.assertNullableOIntegerFksInDatabaseEquals(
-                cachedFks);
+                expectedInDb);
     }
 
     /**



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