You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2020/04/06 16:43:05 UTC

[cayenne] 03/06: Exception in dbimport when relationships should be imported, but no explicit import configuration exists.

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit b4e5eb55b3bf406d78683facece7b7b0942e73e3
Author: Ralf Schuchardt <ra...@gmx.de>
AuthorDate: Sat Apr 4 20:57:38 2020 +0200

    Exception in dbimport when relationships should be imported, but no explicit import configuration exists.
    
    If there is no explicit configuration (included or excluded tables) then sourceTableFilter in RelationshipFilter.checkAndAddRelationship is null and a NullPointerException is thrown.
    
    This is an inconsistent behaviour, because without importing relationships the dbimport itself does work otherwise.
---
 .../dbsync/reverse/dbload/RelationshipLoader.java        | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipLoader.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipLoader.java
index aaefc9a..0d7ce56 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipLoader.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipLoader.java
@@ -120,7 +120,7 @@ public class RelationshipLoader extends AbstractLoader {
                 .tableFilter(relationship.getTargetEntity().getCatalog(), relationship.getTargetEntity().getSchema());
 
         // check that relationship can be included
-        if(!sourceTableFilter.getIncludeTableRelationshipFilter(entity.getName())
+        if(sourceTableFilter != null && !sourceTableFilter.getIncludeTableRelationshipFilter(entity.getName())
                 .isIncluded(relationship.getName())) {
             return;
         }
@@ -131,12 +131,14 @@ public class RelationshipLoader extends AbstractLoader {
             return;
         }
 
-        // check that all join attributes are included
-        for(DbJoin join : relationship.getJoins()) {
-            if(!sourceTableFilter.getIncludeTableColumnFilter(entity.getName()).isIncluded(join.getSourceName()) ||
-                    !targetTableFilter.getIncludeTableColumnFilter(relationship.getTargetEntityName()).isIncluded(join.getTargetName())) {
-                return;
-            }
+        if(sourceTableFilter != null && targetTableFilter != null) {
+	        // check that all join attributes are included
+	        for(DbJoin join : relationship.getJoins()) {
+	            if(!sourceTableFilter.getIncludeTableColumnFilter(entity.getName()).isIncluded(join.getSourceName()) ||
+	                    !targetTableFilter.getIncludeTableColumnFilter(relationship.getTargetEntityName()).isIncluded(join.getTargetName())) {
+	                return;
+	            }
+	        }
         }
 
         // add relationship if delegate permit it