cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r582117 - in /cayenne/main/branches/STABLE-1.2/cayenne: cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ cayenne-java/src/tests/java/org/objectstyle/cayenne/access/ cayenne-java/src/tests/resources/dml/ cayenne-other/release-no...
Date Fri, 05 Oct 2007 08:20:47 GMT
Author: aadamchik
Date: Fri Oct  5 01:20:46 2007
New Revision: 582117

URL: http://svn.apache.org/viewvc?rev=582117&view=rev
Log:
CAY-689 'Null ObjectId' exception from DataContext.localObject()

Modified:
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContextMergeHandler.java
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/NestedDataContextWriteTst.java
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContextMergeHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContextMergeHandler.java?rev=582117&r1=582116&r2=582117&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContextMergeHandler.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContextMergeHandler.java
Fri Oct  5 01:20:46 2007
@@ -200,7 +200,9 @@
         if (source != null && source.getPersistenceState() != PersistenceState.HOLLOW)
{
 
             // get target as local object
-            Object target = context.localObject((ObjectId) targetNodeId, null);
+            Object target = targetNodeId != null ? context.localObject(
+                    (ObjectId) targetNodeId,
+                    null) : null;
 
             Property p = propertyForId(nodeId, arcId.toString());
             if (p instanceof CollectionProperty) {

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/NestedDataContextWriteTst.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/NestedDataContextWriteTst.java?rev=582117&r1=582116&r2=582117&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/NestedDataContextWriteTst.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/NestedDataContextWriteTst.java
Fri Oct  5 01:20:46 2007
@@ -68,6 +68,44 @@
 import org.objectstyle.cayenne.unit.CayenneTestCase;
 
 public class NestedDataContextWriteTst extends CayenneTestCase {
+    
+    /**
+     * A test case for CAY-698 bug.
+     */
+    public void testNullifyToOne() throws Exception {
+        deleteTestData();
+        createTestData("testNullifyToOne");
+
+        DataContext context = createDataContext();
+        DataContext childContext = context.createChildDataContext();
+        DataContext childContextPeer = context.createChildDataContext();
+
+        Painting childP1 = (Painting) DataObjectUtils.objectForPK(
+                childContext,
+                Painting.class,
+                33001);
+
+        // trigger object creation in the peer nested DC
+        DataObjectUtils.objectForPK(childContextPeer, Painting.class, 33001);
+        childP1.setToArtist(null);
+
+        blockQueries();
+
+        try {
+            childContext.commitChangesToParent();
+            assertEquals(PersistenceState.COMMITTED, childP1.getPersistenceState());
+
+            Painting parentP1 = (Painting) context.getGraphManager().getNode(
+                    childP1.getObjectId());
+
+            assertNotNull(parentP1);
+            assertEquals(PersistenceState.MODIFIED, parentP1.getPersistenceState());
+            assertNull(parentP1.getToArtist());
+        }
+        finally {
+            unblockQueries();
+        }
+    }
 
     public void testCommitChangesToParent() throws Exception {
         deleteTestData();

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml?rev=582117&r1=582116&r2=582117&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.NestedDataContextWriteTst.xml
Fri Oct  5 01:20:46 2007
@@ -109,4 +109,13 @@
 		</constructor-arg>
 	</bean>
 	
+	<bean id="testNullifyToOne" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="A1"/>
+				<ref bean="P1"/>
+			</list>
+		</constructor-arg>
+	</bean>
+	
 </beans>

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt?rev=582117&r1=582116&r2=582117&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt
Fri Oct  5 01:20:46 2007
@@ -10,6 +10,7 @@
 
 Bug Fixes:
 
+CAY-689 "Null ObjectId" exception from DataContext.localObject()
 CAY-770 bug / memory leak in DispatchQueue and EventManager
 CAY-796 Deserialization of DataContext fails when useSharedCache is false
 CAY-818 Frontbase NUMBERIC type mapping typo



Mime
View raw message