cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (JIRA)" <j...@apache.org>
Subject [jira] Created: (CAY-1489) NPE using DataContext.objectFromDataRow for a nested context
Date Fri, 08 Oct 2010 12:37:31 GMT
NPE using DataContext.objectFromDataRow for a nested context
------------------------------------------------------------

                 Key: CAY-1489
                 URL: https://issues.apache.org/jira/browse/CAY-1489
             Project: Cayenne
          Issue Type: Bug
    Affects Versions: 3.0.1
            Reporter: Andrus Adamchik
            Assignee: Andrus Adamchik


Getting an NPE trying to build an object from DataRow via a nested context. Exception and
a test case shown below.

java.lang.NullPointerException
	at org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResolver.java:117)
	at org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows(ObjectResolver.java:94)
	at org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.java:598)
	at org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java:646)
	at org.apache.cayenne.access.NestedDataContextReadTest.testObjectFromDataRow(NestedDataContextReadTest.java:490)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



diff --git a/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
b/framework/ca
index 7edddf7..117646c 100644
--- a/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
+++ b/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
@@ -26,6 +26,7 @@ import org.apache.art.Artist;
 import org.apache.art.Painting;
 import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
@@ -475,4 +476,19 @@ public class NestedDataContextReadTest extends CayenneCase {
             unblockQueries();
         }
     }
+    
+    public void testObjectFromDataRow() throws Exception {
+        deleteTestData();
+
+        DataContext context = createDataContext();
+        DataContext childContext = (DataContext) context.createChildContext();
+
+        DataRow row = new DataRow(8);
+        row.put("ARTIST_ID", 5l);
+        row.put("ARTIST_NAME", "A");
+        
+        Artist a = childContext.objectFromDataRow(Artist.class, row, true);
+        assertNotNull(a);
+    }
+


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message