cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] 02/03: Exception in dbimport when relationships should be imported, but no explicit import configuration exists.
Date Mon, 06 Apr 2020 17:13:48 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 409228cdbe9fe67055fa4ac13f9a4966f773fc5e
Author: Ralf Schuchardt <rasc@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 d30f682..2bd96ce 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


Mime
View raw message