cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r582186 - in /cayenne/main/branches/STABLE-2.0/cayenne: cayenne-java/src/cayenne/java/org/apache/cayenne/access/ cayenne-java/src/tests/java/org/apache/cayenne/access/ cayenne-java/src/tests/resources/dml/ cayenne-other/release-notes/
Date Fri, 05 Oct 2007 10:05:12 GMT
Author: aadamchik
Date: Fri Oct  5 03:05:04 2007
New Revision: 582186

URL: http://svn.apache.org/viewvc?rev=582186&view=rev
Log:
CAY-872 Potential bug deleting uncommited objects from a nested DataContext

Modified:
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ChildDiffLoader.java
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/NestedDataContextWriteTst.java
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ChildDiffLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ChildDiffLoader.java?rev=582186&r1=582185&r2=582186&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ChildDiffLoader.java
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ChildDiffLoader.java
Fri Oct  5 03:05:04 2007
@@ -19,6 +19,9 @@
 
 package org.apache.cayenne.access;
 
+import java.util.Collection;
+import java.util.Iterator;
+
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.DataObject;
 import org.apache.cayenne.ObjectId;
@@ -100,6 +103,10 @@
     public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) {
 
         DataObject source = findObject(nodeId);
+        
+        if(source == null) {
+            return;
+        }
 
         // find whether this is to-one or to-many
         ObjEntity sourceEntity = context.getEntityResolver().lookupObjEntity(source);
@@ -132,5 +139,17 @@
 
     DataObject findObject(Object nodeId) {
         return (DataObject) graphManager.getNode(nodeId);
+    }
+    
+    Persistent findObjectInCollection(Object nodeId, Collection toManyHolder) {
+        Iterator it = toManyHolder.iterator();
+        while (it.hasNext()) {
+            Persistent o = (Persistent) it.next();
+            if (nodeId.equals(o.getObjectId())) {
+                return o;
+            }
+        }
+
+        return null;
     }
 }

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/NestedDataContextWriteTst.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/NestedDataContextWriteTst.java?rev=582186&r1=582185&r2=582186&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/NestedDataContextWriteTst.java
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/NestedDataContextWriteTst.java
Fri Oct  5 03:05:04 2007
@@ -32,7 +32,28 @@
 import org.apache.cayenne.unit.CayenneTestCase;
 
 public class NestedDataContextWriteTst extends CayenneTestCase {
-    
+
+    public void testDeleteNew() throws Exception {
+        deleteTestData();
+        createTestData("testDeleteNew");
+
+        DataContext context = createDataContext();
+        DataContext childContext = context.createChildDataContext();
+
+        Artist a = (Artist) DataObjectUtils
+                .objectForPK(childContext, Artist.class, 33001);
+        Painting p = (Painting) childContext.newObject(Painting.class);
+        p.setPaintingTitle("X");
+        a.addToPaintingArray(p);
+
+        childContext.commitChangesToParent();
+
+        childContext.deleteObject(p);
+        a.removeFromPaintingArray(p);
+
+        childContext.commitChangesToParent();
+    }
+
     /**
      * A test case for CAY-698 bug.
      */
@@ -355,7 +376,8 @@
             assertEquals(PersistenceState.NEW, parentMaster.getPersistenceState());
 
             PaintingInfo parentDetail1 = (PaintingInfo) context
-                    .getGraphManager().getNode(childDetail1.getObjectId());
+                    .getGraphManager()
+                    .getNode(childDetail1.getObjectId());
 
             assertNotNull(parentDetail1);
             assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml?rev=582186&r1=582185&r2=582186&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
Fri Oct  5 03:05:04 2007
@@ -118,4 +118,12 @@
 		</constructor-arg>
 	</bean>
 	
+	<bean id="testDeleteNew" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="A1"/>
+			</list>
+		</constructor-arg>
+	</bean>
+	
 </beans>

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt?rev=582186&r1=582185&r2=582186&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
Fri Oct  5 03:05:04 2007
@@ -17,6 +17,7 @@
 CAY-818 Frontbase NUMERIC type mapping typo
 CAY-832 enum-mapped columns improperly handled in in expressions
 CAY-836 Object property unexpectedly set to null through forceMergeWithSnapshot
+CAY-872 Potential bug deleting uncommited objects from a nested DataContext
 
 ----------------------------------
 Release: 2.0.3



Mime
View raw message