cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r705997 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/access/trans/
Date Sun, 19 Oct 2008 12:09:01 GMT
Author: aadamchik
Date: Sun Oct 19 05:09:01 2008
New Revision: 705997

URL: http://svn.apache.org/viewvc?rev=705997&view=rev
Log:
CAY-1025 Do something about to-many prefetch limitations

changing joint prefetches to use OUTER joins - all the tests work

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/JointPrefetchTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectResolver.java?rev=705997&r1=705996&r2=705997&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectResolver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectResolver.java
Sun Oct 19 05:09:01 2008
@@ -118,7 +118,14 @@
         Iterator it = rows.iterator();
 
         while (it.hasNext()) {
-            results.add(objectFromDataRow((DataRow) it.next()));
+            DataRow row = (DataRow) it.next();
+            Persistent object = objectFromDataRow(row);
+            
+            if (object == null) {
+                throw new CayenneRuntimeException("Can't build Object from row: " + row);
+            }
+            
+            results.add(object);
         }
 
         // now deal with snapshots
@@ -159,6 +166,9 @@
 
             DataRow row = (DataRow) it.next();
             Persistent object = objectFromDataRow(row);
+            if (object == null) {
+                throw new CayenneRuntimeException("Can't build Object from row: " + row);
+            }
             results.add(object);
 
             // link with parent
@@ -166,6 +176,14 @@
             // The algorithm below of building an ID doesn't take inheritance into
             // account, so there maybe a miss...
             ObjectId id = createObjectId(row, sourceObjEntity, relatedIdPrefix);
+            if (id == null) {
+                throw new CayenneRuntimeException("Can't build ObjectId from row: "
+                        + row
+                        + ", entity: "
+                        + sourceObjEntity.getName()
+                        + ", prefix: "
+                        + relatedIdPrefix);
+            }
             Persistent parentObject = (Persistent) context.getObjectStore().getNode(id);
 
             // don't attach to hollow objects
@@ -206,6 +224,11 @@
         // all needed metadata already cached.
         ObjectId anId = createObjectId(row, classDescriptor.getEntity(), null);
 
+        // this condition is valid - see comments on 'createObjectId' for details
+        if (anId == null) {
+            return null;
+        }
+
         // this will create a HOLLOW object if it is not registered yet
         Persistent object = context.localObject(anId, null);
 
@@ -277,13 +300,10 @@
                     .getName();
 
             Object val = dataRow.get(key);
+
+            // this is possible when processing left outer joint prefetches
             if (val == null) {
-                throw new CayenneRuntimeException("Null value for '"
-                        + key
-                        + "'. Snapshot: "
-                        + dataRow
-                        + ". Prefix: "
-                        + namePrefix);
+                return null;
             }
 
             // PUT without a prefix

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java?rev=705997&r1=705996&r2=705997&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
Sun Oct 19 05:09:01 2008
@@ -350,6 +350,15 @@
                                 snapshot,
                                 sourceObjEntity,
                                 relatedIdPrefix);
+                        
+                        if (id == null) {
+                            throw new CayenneRuntimeException("Can't build ObjectId from
row: "
+                                    + snapshot
+                                    + ", entity: "
+                                    + sourceObjEntity.getName()
+                                    + ", prefix: "
+                                    + relatedIdPrefix);
+                        }
 
                         sourceObject = (Persistent) objectStore.getNode(id);
                     }
@@ -417,6 +426,11 @@
 
                 DataRow row = processorNode.rowFromFlatRow(currentFlatRow);
                 object = processorNode.getResolver().objectFromDataRow(row);
+                
+                // LEFT OUTER JOIN produced no matches...
+                if(object == null) {
+                    return false;
+                }
 
                 processorNode.putResolved(id, object);
                 processorNode.addObject(object, row);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/JointPrefetchTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/JointPrefetchTest.java?rev=705997&r1=705996&r2=705997&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/JointPrefetchTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/JointPrefetchTest.java
Sun Oct 19 05:09:01 2008
@@ -259,8 +259,7 @@
 
         blockQueries();
         try {
-            // without OUTER join we will get fewer objects...
-            assertEquals(2, objects.size());
+            assertEquals(3, objects.size());
 
             Iterator it = objects.iterator();
             while (it.hasNext()) {
@@ -269,7 +268,6 @@
 
                 assertNotNull(list);
                 assertFalse(((ValueHolder) list).isFault());
-                assertTrue(list.size() > 0);
 
                 Iterator children = list.iterator();
                 while (children.hasNext()) {
@@ -355,8 +353,7 @@
         blockQueries();
         try {
 
-            // without OUTER join we will get fewer objects...
-            assertEquals(2, objects.size());
+            assertEquals(3, objects.size());
 
             Iterator it = objects.iterator();
             while (it.hasNext()) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java?rev=705997&r1=705996&r2=705997&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
Sun Oct 19 05:09:01 2008
@@ -363,7 +363,7 @@
                 transl.createSqlString();
 
                 // assert we only have one join
-                assertEquals(1, transl.joinStack.size());
+                assertEquals(2, transl.joinStack.size());
             }
         };
 



Mime
View raw message