cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/9] cayenne git commit: New DbLoader for dbsync utils - loading process split in independent small steps - DbLoader always return new DataMap, it doesn't accept it from outside
Date Wed, 14 Dec 2016 18:29:50 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 1f6100db2 -> 836399cba


http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
new file mode 100644
index 0000000..bf0f89f
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
@@ -0,0 +1,105 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.dbsync.reverse.dbload;
+
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.TypesMapping;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.NoStemStemmer;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.CayenneProjects;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.junit.After;
+import org.junit.Before;
+
+import java.sql.Connection;
+
+/**
+ * All tests have been moved to corresponding loaders tests.
+ */
+@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
+public class DbLoaderIT extends ServerCase {
+
+    public static final DbLoaderConfiguration CONFIG = new DbLoaderConfiguration();
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DbAdapter adapter;
+
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+
+    @Inject
+    private UnitDbAdapter accessStackAdapter;
+
+    private Connection connection;
+
+    private static String msgForTypeMismatch(DbAttribute origAttr, DbAttribute newAttr) {
+        return msgForTypeMismatch(origAttr.getType(), newAttr);
+    }
+
+    private static String msgForTypeMismatch(int origType, DbAttribute newAttr) {
+        String nt = TypesMapping.getSqlNameByType(newAttr.getType());
+        String ot = TypesMapping.getSqlNameByType(origType);
+        return attrMismatch(newAttr.getName(), "expected type: <" + ot + ">, but was <" + nt + ">");
+    }
+
+    private static String attrMismatch(String attrName, String msg) {
+        return "[Error loading attribute '" + attrName + "': " + msg + "]";
+    }
+
+    @Before
+    public void before() throws Exception {
+        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
+    }
+
+    private DbLoader createDbLoader(boolean meaningfulPK, boolean meaningfulFK) {
+        return new DbLoader(adapter, connection, CONFIG, null, new DefaultObjectNameGenerator(NoStemStemmer.getInstance()));
+    }
+
+    @After
+    public void after() throws Exception {
+        connection.close();
+    }
+
+    private void assertUniqueConstraintsInRelationships(DataMap map) {
+        // unfortunately JDBC metadata doesn't provide info for UNIQUE
+        // constraints....
+        // cant reengineer them...
+        // upd. actually it's provided:
+        // http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getIndexInfo%28java.lang.String,%20java.lang.String,%20java.lang.String,%20boolean,%20boolean%29
+
+        // find rel to TO_ONEFK1
+        /*
+         * Iterator it = getDbEntity(map,
+         * "TO_ONEFK2").getRelationships().iterator(); DbRelationship rel =
+         * (DbRelationship) it.next(); assertEquals("TO_ONEFK1",
+         * rel.getTargetEntityName());
+         * assertFalse("UNIQUE constraint was ignored...", rel.isToMany());
+         */
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/EntityLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/EntityLoaderIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/EntityLoaderIT.java
new file mode 100644
index 0000000..b05bc21
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/EntityLoaderIT.java
@@ -0,0 +1,98 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.dbsync.reverse.dbload;
+
+import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
+import org.apache.cayenne.dbsync.reverse.filters.PatternFilter;
+import org.apache.cayenne.dbsync.reverse.filters.TableFilter;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+
+public class EntityLoaderIT extends BaseLoaderIT {
+
+    @Test
+    public void testGetTablesWithWrongCatalog() throws Exception {
+        DbLoaderConfiguration config = new DbLoaderConfiguration();
+        config.setFiltersConfig(
+                FiltersConfig.create("WRONG", null, TableFilter.everything(), PatternFilter.INCLUDE_NOTHING)
+        );
+
+        EntityLoader loader = new EntityLoader(adapter, config, new DefaultDbLoaderDelegate());
+        loader.load(connection.getMetaData(), store);
+
+        assertTrue("Store is not empty", store.getDbEntities().isEmpty());
+    }
+
+    @Test
+    public void testGetTablesWithWrongSchema() throws Exception {
+        DbLoaderConfiguration config = new DbLoaderConfiguration();
+        config.setFiltersConfig(
+                FiltersConfig.create(null, "WRONG", TableFilter.everything(), PatternFilter.INCLUDE_NOTHING)
+        );
+
+        EntityLoader loader = new EntityLoader(adapter, config, new DefaultDbLoaderDelegate());
+        loader.load(connection.getMetaData(), store);
+
+        assertTrue("Store is not empty", store.getDbEntities().isEmpty());
+    }
+
+    @Test
+    public void testLoad() throws Exception {
+
+        EntityLoader loader = new EntityLoader(adapter, EMPTY_CONFIG, new DefaultDbLoaderDelegate());
+        loader.load(connection.getMetaData(), store);
+
+        assertFalse("Store not empty", store.getDbEntities().isEmpty());
+        assertDbEntities();
+
+        if(accessStackAdapter.supportsLobs()) {
+            assertLobDbEntities();
+        }
+    }
+
+    private void assertDbEntities() {
+        DbEntity dae = getDbEntity("ARTIST");
+        assertNotNull("Null 'ARTIST' entity, other DbEntities: " + store.getDbEntityMap(), dae);
+        assertEquals("ARTIST", dae.getName().toUpperCase());
+
+        if (adapter.supportsGeneratedKeys()) {
+            DbEntity bag = getDbEntity("GENERATED_COLUMN_TEST");
+            assertNotNull("Null 'GENERATED_COLUMN_TEST' entity, other DbEntities: " + store.getDbEntityMap(), bag);
+        }
+    }
+
+    private void assertLobDbEntities() {
+        DbEntity blobEnt = getDbEntity("BLOB_TEST");
+        assertNotNull(blobEnt);
+
+        DbEntity clobEnt = getDbEntity("CLOB_TEST");
+        assertNotNull(clobEnt);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
new file mode 100644
index 0000000..9c71159
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
@@ -0,0 +1,71 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.dbsync.reverse.dbload;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExportedKeyLoaderIT extends BaseLoaderIT {
+
+    @Test
+    public void testExportedKeyLoad() throws Exception {
+        boolean supportsFK = accessStackAdapter.supportsFKConstraints();
+        if(!supportsFK) {
+            return;
+        }
+
+        createEntity("ARTIST");
+        createEntity("GALLERY");
+        createEntity("PAINTING");
+        DbEntity artist = getDbEntity("ARTIST");
+        DbAttribute artistId = new DbAttribute("ARTIST_ID");
+        artist.addAttribute(artistId);
+
+        DbEntity gallery = getDbEntity("GALLERY");
+        DbAttribute galleryId = new DbAttribute("GALLERY_ID");
+        gallery.addAttribute(galleryId);
+
+        DbEntity painting = getDbEntity("PAINTING");
+        DbAttribute paintingId = new DbAttribute("PAINTING_ID");
+        DbAttribute paintingArtistId = new DbAttribute("ARTIST_ID");
+        DbAttribute paintingGalleryId = new DbAttribute("GALLERY_ID");
+        painting.addAttribute(paintingId);
+        painting.addAttribute(paintingArtistId);
+        painting.addAttribute(paintingGalleryId);
+
+        ExportedKeyLoader loader = new ExportedKeyLoader(EMPTY_CONFIG, new DefaultDbLoaderDelegate());
+        loader.load(connection.getMetaData(), store);
+
+        assertEquals(2, store.getExportedKeysEntrySet().size());
+
+        ExportedKey artistIdFk = store.getExportedKeysEntrySet()
+                .iterator().next()
+                .getValue().iterator().next();
+        assertEquals("ARTIST", artistIdFk.getPk().getTable());
+        assertEquals("ARTIST_ID", artistIdFk.getPk().getColumn());
+
+        assertEquals("PAINTING", artistIdFk.getFk().getTable());
+        assertEquals("ARTIST_ID", artistIdFk.getFk().getColumn());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
new file mode 100644
index 0000000..56be301
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
@@ -0,0 +1,60 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.dbsync.reverse.dbload;
+
+import java.util.Collection;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class PrimaryKeyLoaderIT extends BaseLoaderIT {
+
+    @Test
+    public void testPrimaryKeyLoad() throws Exception {
+        createDbEntities();
+        DbEntity artist = getDbEntity("ARTIST");
+        DbAttribute artistId = new DbAttribute("ARTIST_ID");
+        DbAttribute artistName = new DbAttribute("ARTIST_NAME");
+        DbAttribute artistId1 = new DbAttribute("ARTIST_ID1");
+
+        artist.addAttribute(artistId);
+        artist.addAttribute(artistName);
+        artist.addAttribute(artistId1);
+        assertFalse(artistId.isPrimaryKey());
+        assertFalse(artistName.isPrimaryKey());
+        assertFalse(artistId1.isPrimaryKey());
+
+        PrimaryKeyLoader loader = new PrimaryKeyLoader(EMPTY_CONFIG, new DefaultDbLoaderDelegate());
+        loader.load(connection.getMetaData(), store);
+
+        assertTrue(artistId.isPrimaryKey());
+        assertFalse(artistId1.isPrimaryKey());
+        assertFalse(artistName.isPrimaryKey());
+        Collection<DbAttribute> pk = artist.getPrimaryKeys();
+        assertEquals(1, pk.size());
+        assertEquals(artistId, pk.iterator().next());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipsLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipsLoaderIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipsLoaderIT.java
new file mode 100644
index 0000000..a73833e
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/RelationshipsLoaderIT.java
@@ -0,0 +1,82 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.dbsync.reverse.dbload;
+
+import java.sql.DatabaseMetaData;
+import java.util.Collection;
+
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.map.DbRelationship;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class RelationshipsLoaderIT extends BaseLoaderIT {
+
+    @Test
+    public void testRelationshipLoad() throws Exception {
+        boolean supportsFK = accessStackAdapter.supportsFKConstraints();
+        if(!supportsFK) {
+            return;
+        }
+
+        DatabaseMetaData metaData = connection.getMetaData();
+        DbLoaderDelegate delegate = new DefaultDbLoaderDelegate();
+
+        // We need all data to check relationships, so simply load it all
+        EntityLoader entityLoader = new EntityLoader(adapter, EMPTY_CONFIG, delegate);
+        AttributeLoader attributeLoader = new AttributeLoader(adapter, EMPTY_CONFIG, delegate);
+        PrimaryKeyLoader primaryKeyLoader = new PrimaryKeyLoader(EMPTY_CONFIG, delegate);
+        ExportedKeyLoader exportedKeyLoader = new ExportedKeyLoader(EMPTY_CONFIG, delegate);
+
+        entityLoader.load(metaData, store);
+        attributeLoader.load(metaData, store);
+        primaryKeyLoader.load(metaData, store);
+        exportedKeyLoader.load(metaData, store);
+
+        // *** TESTING THIS ***
+        RelationshipLoader relationshipLoader = new RelationshipLoader(EMPTY_CONFIG, delegate, new DefaultObjectNameGenerator());
+        relationshipLoader.load(metaData, store);
+
+        Collection<DbRelationship> rels = getDbEntity("ARTIST").getRelationships();
+        assertNotNull(rels);
+        assertTrue(!rels.isEmpty());
+
+        // test one-to-one
+        rels = getDbEntity("PAINTING").getRelationships();
+        assertNotNull(rels);
+
+        // find relationship to PAINTING_INFO
+        DbRelationship oneToOne = null;
+        for (DbRelationship rel : rels) {
+            if ("PAINTING_INFO".equalsIgnoreCase(rel.getTargetEntityName())) {
+                oneToOne = rel;
+                break;
+            }
+        }
+
+        assertNotNull("No relationship to PAINTING_INFO", oneToOne);
+        assertFalse("Relationship to PAINTING_INFO must be to-one", oneToOne.isToMany());
+        assertTrue("Relationship to PAINTING_INFO must be to-one", oneToOne.isToDependentPK());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/TableFilterTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/TableFilterTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/TableFilterTest.java
index 979b20f..4ef3c23 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/TableFilterTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/TableFilterTest.java
@@ -18,13 +18,17 @@
  ****************************************************************/
 package org.apache.cayenne.dbsync.reverse.filters;
 
-import junit.framework.TestCase;
-
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 
-public class TableFilterTest extends TestCase {
+import org.apache.cayenne.dbimport.ExcludeTable;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TableFilterTest {
 
+    @Test
     public void testIncludeEverything() {
         TableFilter filter = TableFilter.everything();
 
@@ -34,58 +38,79 @@ public class TableFilterTest extends TestCase {
         assertNotNull(filter.isIncludeTable("alex"));
     }
 
+    @Test
     public void testInclude() {
-        TreeSet<IncludeTableFilter> includes = new TreeSet<IncludeTableFilter>();
+        TreeSet<IncludeTableFilter> includes = new TreeSet<>();
         includes.add(new IncludeTableFilter("aaa"));
         includes.add(new IncludeTableFilter("bb"));
 
-        TableFilter filter = new TableFilter(includes, new TreeSet<Pattern>(PatternFilter.PATTERN_COMPARATOR));
+        TableFilter filter = new TableFilter(includes, new TreeSet<>(PatternFilter.PATTERN_COMPARATOR));
 
-        assertNotNull(filter.isIncludeTable("aaa"));
-        assertNull(filter.isIncludeTable("aa"));
-        assertNull(filter.isIncludeTable("aaaa"));
+        assertTrue(filter.isIncludeTable("aaa"));
+        assertFalse(filter.isIncludeTable("aa"));
+        assertFalse(filter.isIncludeTable("aaaa"));
 
-        assertNotNull(filter.isIncludeTable("bb"));
-        assertNull(filter.isIncludeTable(""));
-        assertNull(filter.isIncludeTable("bbbb"));
+        assertTrue(filter.isIncludeTable("bb"));
+        assertFalse(filter.isIncludeTable(""));
+        assertFalse(filter.isIncludeTable("bbbb"));
     }
 
-
+    @Test
     public void testExclude() {
-        TreeSet<Pattern> excludes = new TreeSet<Pattern>(PatternFilter.PATTERN_COMPARATOR);
+        TreeSet<Pattern> excludes = new TreeSet<>(PatternFilter.PATTERN_COMPARATOR);
         excludes.add(Pattern.compile("aaa"));
         excludes.add(Pattern.compile("bb"));
 
-        TreeSet<IncludeTableFilter> includes = new TreeSet<IncludeTableFilter>();
+        TreeSet<IncludeTableFilter> includes = new TreeSet<>();
         includes.add(new IncludeTableFilter(null, PatternFilter.INCLUDE_EVERYTHING));
 
         TableFilter filter = new TableFilter(includes, excludes);
 
-        assertNull(filter.isIncludeTable("aaa"));
-        assertNotNull(filter.isIncludeTable("aa"));
-        assertNotNull(filter.isIncludeTable("aaaa"));
+        assertFalse(filter.isIncludeTable("aaa"));
+        assertTrue(filter.isIncludeTable("aa"));
+        assertTrue(filter.isIncludeTable("aaaa"));
 
-        assertNull(filter.isIncludeTable("bb"));
-        assertNotNull(filter.isIncludeTable(""));
-        assertNotNull(filter.isIncludeTable("bbbb"));
+        assertFalse(filter.isIncludeTable("bb"));
+        assertTrue(filter.isIncludeTable(""));
+        assertTrue(filter.isIncludeTable("bbbb"));
     }
 
+    @Test
     public void testIncludeExclude() {
-        TreeSet<Pattern> excludes = new TreeSet<Pattern>(PatternFilter.PATTERN_COMPARATOR);
+        TreeSet<Pattern> excludes = new TreeSet<>(PatternFilter.PATTERN_COMPARATOR);
         excludes.add(Pattern.compile("aaa"));
         excludes.add(Pattern.compile("bb"));
 
-        TreeSet<IncludeTableFilter> includes = new TreeSet<IncludeTableFilter>();
+        TreeSet<IncludeTableFilter> includes = new TreeSet<>();
         includes.add(new IncludeTableFilter("aa.*"));
 
         TableFilter filter = new TableFilter(includes, excludes);
 
-        assertNull(filter.isIncludeTable("aaa"));
-        assertNotNull(filter.isIncludeTable("aa"));
-        assertNotNull(filter.isIncludeTable("aaaa"));
+        assertFalse(filter.isIncludeTable("aaa"));
+        assertTrue(filter.isIncludeTable("aa"));
+        assertTrue(filter.isIncludeTable("aaaa"));
+
+        assertFalse(filter.isIncludeTable("bb"));
+        assertFalse(filter.isIncludeTable(""));
+        assertFalse(filter.isIncludeTable("bbbb"));
+    }
+
+    @Test
+    public void testGetTableFilter() {
+        TreeSet<IncludeTableFilter> includes = new TreeSet<IncludeTableFilter>();
+        includes.add(new IncludeTableFilter("aaa"));
+        includes.add(new IncludeTableFilter("bb"));
+
+        TreeSet<Pattern> excludes = new TreeSet<>();
+
+        TableFilter filter = new TableFilter(includes, excludes);
+
+        assertNotNull(filter.getIncludeTableColumnFilter("aaa"));
+        assertNull(filter.getIncludeTableColumnFilter("aa"));
+        assertNull(filter.getIncludeTableColumnFilter("aaaa"));
 
-        assertNull(filter.isIncludeTable("bb"));
-        assertNull(filter.isIncludeTable(""));
-        assertNull(filter.isIncludeTable("bbbb"));
+        assertNotNull(filter.getIncludeTableColumnFilter("bb"));
+        assertNull(filter.getIncludeTableColumnFilter(""));
+        assertNull(filter.getIncludeTableColumnFilter("bbbb"));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
index 681d353..720ce54 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
@@ -31,10 +31,10 @@ import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.NoStemStemmer;
 import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.PatternStemmer;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderConfiguration;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderDelegate;
-import org.apache.cayenne.dbsync.reverse.db.DefaultDbLoaderDelegate;
-import org.apache.cayenne.dbsync.reverse.db.LoggingDbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DefaultDbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.LoggingDbLoaderDelegate;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
 import org.apache.commons.logging.Log;
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
index 331a155..24466b3 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
@@ -34,9 +34,8 @@ import org.apache.cayenne.dbsync.merge.TokenComparator;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
 import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderConfiguration;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration;
 import org.apache.cayenne.dbsync.reverse.filters.CatalogFilter;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
 import org.apache.cayenne.dbsync.reverse.filters.PatternFilter;
@@ -143,7 +142,7 @@ public class DefaultDbImportAction implements DbImportAction {
 
         DataMap sourceDataMap;
         try (Connection connection = dataSource.getConnection()) {
-            sourceDataMap = load(config, adapter, connection, objectNameGenerator);
+            sourceDataMap = load(config, adapter, connection);
         }
 
         DataMap targetDataMap = existingTargetMap(config);
@@ -409,19 +408,16 @@ public class DefaultDbImportAction implements DbImportAction {
 
     protected DataMap load(DbImportConfiguration config,
                            DbAdapter adapter,
-                           Connection connection,
-                           ObjectNameGenerator objectNameGenerator) throws Exception {
-
-        DataMap dataMap = new DataMap("_import_source_");
-        createDbLoader(adapter, connection, config.createLoaderDelegate(), objectNameGenerator)
-                .load(dataMap, config.getDbLoaderConfig());
-        return dataMap;
+                           Connection connection) throws Exception {
+        return createDbLoader(adapter, connection, config).load();
     }
 
     protected DbLoader createDbLoader(DbAdapter adapter,
-                                      Connection connection,
-                                      DbLoaderDelegate dbLoaderDelegate,
-                                      ObjectNameGenerator objectNameGenerator) {
-        return new DbLoader(connection, adapter, dbLoaderDelegate, objectNameGenerator);
+                                       Connection connection,
+                                       DbImportConfiguration config) {
+        return new DbLoader(adapter, connection,
+                config.getDbLoaderConfig(),
+                config.createLoaderDelegate(),
+                config.createNameGenerator());
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
index aa635b2..855d3ee 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
@@ -37,9 +37,9 @@ import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
 import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.NoStemStemmer;
 import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderConfiguration;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
@@ -113,21 +113,22 @@ public class DefaultDbImportActionTest {
     @Test
     public void testNewDataMapImport() throws Exception {
 
-        DbLoader dbLoader = new DbLoader(mockConnection, mockAdapter, mockDelegate, mockNameGenerator) {
-            @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException {
-                new DataMapBuilder(dataMap).withDbEntities(2).build();
-            }
-        };
-
         DbImportConfiguration config = mock(DbImportConfiguration.class);
-
         when(config.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate());
         when(config.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration());
         when(config.getTargetDataMap()).thenReturn(new File("xyz.map.xml"));
         when(config.createNameGenerator()).thenReturn(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()));
         when(config.createMeaningfulPKFilter()).thenReturn(NamePatternMatcher.EXCLUDE_ALL);
 
+        DbLoader dbLoader = new DbLoader(mockAdapter, mockConnection, config.getDbLoaderConfig(), mockDelegate, mockNameGenerator) {
+            @Override
+            public DataMap load() throws SQLException {
+                DataMap map = new DataMap();
+                new DataMapBuilder(map).withDbEntities(2).build();
+                return map;
+            }
+        };
+
         final boolean[] haveWeTriedToSave = {false};
         DefaultDbImportAction action = buildDbImportAction(new FileProjectSaver() {
             @Override
@@ -146,9 +147,19 @@ public class DefaultDbImportActionTest {
 
     @Test
     public void testImportWithFieldChanged() throws Exception {
-        DbLoader dbLoader = new DbLoader(mockConnection, mockAdapter, mockDelegate, mockNameGenerator) {
+
+        DbImportConfiguration config = mock(DbImportConfiguration.class);
+
+        when(config.getTargetDataMap()).thenReturn(FILE_STUB);
+        when(config.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate());
+        when(config.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration());
+        when(config.createNameGenerator()).thenReturn(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()));
+        when(config.createMeaningfulPKFilter()).thenReturn(NamePatternMatcher.EXCLUDE_ALL);
+
+        DbLoader dbLoader = new DbLoader(mockAdapter, mockConnection, config.getDbLoaderConfig(), mockDelegate, mockNameGenerator) {
             @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException {
+            public DataMap load() throws SQLException {
+                DataMap dataMap = new DataMap();
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("GROUP_ID").typeInt().primaryKey(),
@@ -159,72 +170,70 @@ public class DefaultDbImportActionTest {
                         objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes(
                                 objAttr("name").type(String.class).dbPath("NAME")
                         ));
+                return dataMap;
             }
         };
 
-        DbImportConfiguration params = mock(DbImportConfiguration.class);
-
-        when(params.getTargetDataMap()).thenReturn(FILE_STUB);
-        when(params.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate());
-        when(params.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration());
-        when(params.createNameGenerator()).thenReturn(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()));
-        when(params.createMeaningfulPKFilter()).thenReturn(NamePatternMatcher.EXCLUDE_ALL);
-
         final boolean[] haveWeTriedToSave = {false};
-        DefaultDbImportAction action = buildDbImportAction(new FileProjectSaver() {
-            @Override
-            public void save(Project project) {
-                haveWeTriedToSave[0] = true;
+        DefaultDbImportAction action = buildDbImportAction(
+            new FileProjectSaver() {
+                @Override
+                public void save(Project project) {
+                    haveWeTriedToSave[0] = true;
+
+                    // Validation phase
+                    DataMap rootNode = (DataMap) project.getRootNode();
+                    assertEquals(1, rootNode.getObjEntities().size());
+                    assertEquals(1, rootNode.getDbEntityMap().size());
+
+                    DbEntity entity = rootNode.getDbEntity("ARTGROUP");
+                    assertNotNull(entity);
+                    assertEquals(4, entity.getAttributes().size());
+                    assertNotNull(entity.getAttribute("NAME_01"));
+                }
+            },
+
+            new MapLoader() {
+                @Override
+                public synchronized DataMap loadDataMap(InputSource src) throws CayenneRuntimeException {
+                    return new DataMapBuilder().with(
+                            dbEntity("ARTGROUP").attributes(
+                                    dbAttr("GROUP_ID").typeInt().primaryKey(),
+                                    dbAttr("NAME").typeVarchar(100).mandatory(),
+                                    dbAttr("PARENT_GROUP_ID").typeInt()
+                            )).with(
+                            objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes(
+                                    objAttr("name").type(String.class).dbPath("NAME")
+                            )).build();
+                }
+            },
+            dbLoader
+        );
 
-                // Validation phase
-                DataMap rootNode = (DataMap) project.getRootNode();
-                assertEquals(1, rootNode.getObjEntities().size());
-                assertEquals(1, rootNode.getDbEntityMap().size());
-
-                DbEntity entity = rootNode.getDbEntity("ARTGROUP");
-                assertNotNull(entity);
-                assertEquals(4, entity.getAttributes().size());
-                assertNotNull(entity.getAttribute("NAME_01"));
-            }
-        }, new MapLoader() {
-
-            @Override
-            public synchronized DataMap loadDataMap(InputSource src) throws CayenneRuntimeException {
-                return new DataMapBuilder().with(
-                        dbEntity("ARTGROUP").attributes(
-                                dbAttr("GROUP_ID").typeInt().primaryKey(),
-                                dbAttr("NAME").typeVarchar(100).mandatory(),
-                                dbAttr("PARENT_GROUP_ID").typeInt()
-                        )).with(
-                        objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes(
-                                objAttr("name").type(String.class).dbPath("NAME")
-                        )).build();
-            }
-        }, dbLoader);
-
-        action.execute(params);
+        action.execute(config);
 
         assertTrue("We should try to save.", haveWeTriedToSave[0]);
     }
 
     @Test
     public void testImportWithoutChanges() throws Exception {
-        DbLoader dbLoader = new DbLoader(mockConnection, mockAdapter, mockDelegate, mockNameGenerator) {
+        DbImportConfiguration config = mock(DbImportConfiguration.class);
+        when(config.getTargetDataMap()).thenReturn(FILE_STUB);
+        when(config.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate());
+        when(config.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration());
+
+        DbLoader dbLoader = new DbLoader(mockAdapter, mockConnection, config.getDbLoaderConfig(), mockDelegate, mockNameGenerator) {
             @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException {
+            public DataMap load() throws SQLException {
+                DataMap dataMap = new DataMap();
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("NAME").typeVarchar(100).mandatory()
                         ));
+                return dataMap;
             }
         };
 
-        DbImportConfiguration params = mock(DbImportConfiguration.class);
-        when(params.getTargetDataMap()).thenReturn(FILE_STUB);
-        when(params.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate());
-        when(params.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration());
-
-
         FileProjectSaver projectSaver = mock(FileProjectSaver.class);
         doNothing().when(projectSaver).save(any(Project.class));
 
@@ -236,7 +245,7 @@ public class DefaultDbImportActionTest {
 
         DefaultDbImportAction action = buildDbImportAction(projectSaver, mapLoader, dbLoader);
 
-        action.execute(params);
+        action.execute(config);
 
         // no changes - we still
         verify(projectSaver, never()).save(any(Project.class));
@@ -246,7 +255,7 @@ public class DefaultDbImportActionTest {
     @Test
     public void testImportWithDbError() throws Exception {
         DbLoader dbLoader = mock(DbLoader.class);
-        doThrow(new SQLException()).when(dbLoader).load(any(DataMap.class), any(DbLoaderConfiguration.class));
+        doThrow(new SQLException()).when(dbLoader).load();
 
         DbImportConfiguration params = mock(DbImportConfiguration.class);
 
@@ -290,11 +299,9 @@ public class DefaultDbImportActionTest {
 
         return new DefaultDbImportAction(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader, mergerTokenFactoryProvider) {
 
-            @Override
             protected DbLoader createDbLoader(DbAdapter adapter,
-                                              Connection connection,
-                                              DbLoaderDelegate dbLoaderDelegate,
-                                              ObjectNameGenerator objectNameGenerator) {
+                                               Connection connection,
+                                               DbImportConfiguration config) {
                 return dbLoader;
             }
         };

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
index 00e27bf..0648d2c 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
@@ -21,7 +21,7 @@ package org.apache.cayenne.modeler.action;
 
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.db.DataSourceController;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
index d314214..0f49e49 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
@@ -33,8 +33,8 @@ import org.apache.cayenne.dbimport.Schema;
 import org.apache.cayenne.dbsync.DbSyncModule;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
 import org.apache.cayenne.dbsync.naming.NameBuilder;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.db.DefaultDbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
+import org.apache.cayenne.dbsync.reverse.dbload.DefaultDbLoaderDelegate;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
@@ -68,7 +68,7 @@ import java.util.Collections;
 import java.util.List;
 
 /**
- * Stateful helper class that encapsulates access to DbLoader.
+ * Stateful helper class that encapsulates access to DbLoader2.
  */
 public class DbLoaderHelper {
 
@@ -377,7 +377,7 @@ public class DbLoaderHelper {
             ProjectUtil.cleanObjMappings(dataMap);
         }
 
-        protected DbImportAction createAction(DataMap targetDataMap) {
+        DbImportAction createAction(DataMap targetDataMap) {
             Injector injector = DIBootstrap.createInjector(new DbSyncModule(),
                     new ToolsModule(LOGGER),
                     new DbImportModule());
@@ -393,8 +393,8 @@ public class DbLoaderHelper {
                     createDbLoader(config));
         }
 
-        protected DbLoader createDbLoader(DbImportConfiguration configuration) {
-            return new DbLoader(connection, adapter, new LoaderDelegate(), configuration.createNameGenerator());
+        DbLoader createDbLoader(DbImportConfiguration configuration) {
+            return new DbLoader(adapter, connection, configuration.getDbLoaderConfig(), new LoaderDelegate(), configuration.createNameGenerator());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
index 52a3666..b74fc73 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
@@ -34,9 +34,9 @@ import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
 import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.NoStemStemmer;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderConfiguration;
-import org.apache.cayenne.dbsync.reverse.db.LoggingDbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbload.LoggingDbLoaderDelegate;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
 import org.apache.cayenne.dbsync.reverse.filters.PatternFilter;
 import org.apache.cayenne.dbsync.reverse.filters.TableFilter;
@@ -169,14 +169,13 @@ public class MergerOptions extends CayenneController {
 
             DataSource dataSource = connectionInfo.makeDataSource(getApplication().getClassLoadingService());
 
-            DataMap dbImport = new DataMap();
+            DataMap dbImport;
             try (Connection conn = dataSource.getConnection();) {
-                new DbLoader(conn,
-                        adapter,
+                dbImport = new DbLoader(adapter, conn,
+                        config,
                         new LoggingDbLoaderDelegate(LogFactory.getLog(DbLoader.class)),
                         new DefaultObjectNameGenerator(NoStemStemmer.getInstance()))
-                        .load(dbImport, config);
-
+                        .load();
             } catch (SQLException e) {
                 throw new CayenneRuntimeException("Can't doLoad dataMap from db.", e);
             }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/8c273022/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ModelerDbImportAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ModelerDbImportAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ModelerDbImportAction.java
index 1b271bb..e645e0e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ModelerDbImportAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ModelerDbImportAction.java
@@ -22,9 +22,7 @@ import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
-import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.db.DbLoaderDelegate;
+import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.MapLoader;
 import org.apache.cayenne.project.ProjectSaver;
@@ -47,8 +45,7 @@ public class ModelerDbImportAction extends DefaultDbImportAction {
                                  MapLoader mapLoader,
                                  MergerTokenFactoryProvider mergerTokenFactoryProvider,
                                  DataMap targetMap,
-                                 DbLoader dbLoader
-                                 ) {
+                                 DbLoader dbLoader) {
 
         super(logger, projectSaver, dataSourceFactory, adapterFactory, mapLoader, mergerTokenFactoryProvider);
 
@@ -58,9 +55,8 @@ public class ModelerDbImportAction extends DefaultDbImportAction {
 
     @Override
     protected DbLoader createDbLoader(DbAdapter adapter,
-                                      Connection connection,
-                                      DbLoaderDelegate dbLoaderDelegate,
-                                      ObjectNameGenerator objectNameGenerator) {
+                                       Connection connection,
+                                       DbImportConfiguration config) {
         return dbLoader;
     }
 


Mime
View raw message