cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1509573 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/
Date Fri, 02 Aug 2013 07:34:11 GMT
Author: aadamchik
Date: Fri Aug  2 07:34:11 2013
New Revision: 1509573

URL: http://svn.apache.org/r1509573
Log:
CAY-1859  NullPointerException when importing EOModel

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOObjEntity.java
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOQuery.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1509573&r1=1509572&r2=1509573&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Aug  2 07:34:11 2013
@@ -27,6 +27,7 @@ Bug Fixes:
 CAY-1695 Unexpected null value in bidirectional one-to-one prefetch 
 CAY-1736 IllegalArgumentException when synchronizing entities in the Modeler
 CAY-1857 Problem with hotkeys 
+CAY-1859 NullPointerException when importing EOModel 
 
 ----------------------------------
 Release: 3.2M1

Modified: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOObjEntity.java?rev=1509573&r1=1509572&r2=1509573&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOObjEntity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOObjEntity.java
Fri Aug  2 07:34:11 2013
@@ -29,9 +29,11 @@ import java.util.StringTokenizer;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionException;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.query.Query;
 import org.apache.commons.collections.Transformer;
 
@@ -39,7 +41,7 @@ import org.apache.commons.collections.Tr
  * An extension of ObjEntity used to accomodate extra EOModel entity properties.
  */
 public class EOObjEntity extends ObjEntity {
-
+    
     protected boolean subclass;
     protected boolean abstractEntity;
 
@@ -200,9 +202,12 @@ public class EOObjEntity extends ObjEnti
 
                     buffer.append(chunk);
 
-                    entity = (EOObjEntity) entity
-                            .getRelationship(chunk)
-                            .getTargetEntity();
+                    Relationship r = entity.getRelationship(chunk);
+                    if (r == null) {
+                        throw new ExpressionException("Invalid path component: " + chunk);
+                    }
+
+                    entity = (EOObjEntity) r.getTargetEntity();
                 }
                 // this is an attribute...
                 else {

Modified: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOQuery.java?rev=1509573&r1=1509572&r2=1509573&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOQuery.java
Fri Aug  2 07:34:11 2013
@@ -496,9 +496,12 @@ public class EOQuery<T> extends SelectQu
             Expression keyExp = Expression.fromString(key);
             try {
                 entity.lastPathComponent(keyExp, Collections.emptyMap());
-            }
-            catch (ExpressionException e) {
-                keyExp = entity.translateToDbPath(keyExp);
+            } catch (ExpressionException e) {
+                try {
+                    keyExp = entity.translateToDbPath(keyExp);
+                } catch (Exception dbpathEx) {
+                    return null;
+                }
             }
 
             try {



Mime
View raw message