cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [06/15] cayenne git commit: CAY-2116 Split schema synchronization code in a separate module
Date Thu, 29 Sep 2016 17:38:52 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseMergerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseMergerFactory.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseMergerFactory.java
deleted file mode 100644
index 9750aeb..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseMergerFactory.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*****************************************************************
- *   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.dba.openbase;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.merge.CreateTableToDb;
-import org.apache.cayenne.merge.DropRelationshipToDb;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.merge.MergerToken;
-import org.apache.cayenne.merge.SetAllowNullToDb;
-import org.apache.cayenne.merge.SetColumnTypeToDb;
-import org.apache.cayenne.merge.SetNotNullToDb;
-
-public class OpenBaseMergerFactory extends MergerFactory {
-
-    @Override
-    public MergerToken createCreateTableToDb(DbEntity entity) {
-        return new CreateTableToDb(entity) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                List<String> sqls = new ArrayList<String>();
-                // create table first as OpenBase adapter created primary key in its
-                // getPkGenerator().createAutoPkStatements
-                sqls.add(adapter.createTable(getEntity()));
-                sqls.addAll(adapter.getPkGenerator().createAutoPkStatements(
-                        Collections.singletonList(getEntity())));
-                return sqls;
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createDropRelationshipToDb(
-            final DbEntity entity,
-            final DbRelationship rel) {
-        return new DropRelationshipToDb(entity, rel) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-
-
-                // FK_NAME form jdbc metadata seem to be wrong. It contain a column name
-                // and not the 'relationshipName'
-                // TODO: tell openbase developer mail list
-
-                DbEntity source = getEntity();
-                DbEntity dest = rel.getTargetEntity();
-
-                // only use the first. See adapter
-                // TODO: can we be sure this is the first and same as used by the adapter?
-                DbJoin join = rel.getJoins().get(0);
-
-                // see comment in adapter for why source and dest is switched around..
-
-                return Collections.singletonList("delete from _SYS_RELATIONSHIP where "
-                        + " source_table = '" + dest.getFullyQualifiedName() + "'"
-                        + " and source_column = '" + join.getTargetName() + "'"
-                        + " and dest_table = '" + source.getFullyQualifiedName() + "'"
-                        + " and dest_column = '" + join.getSourceName() + "'");
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            final DbAttribute columnOriginal,
-            final DbAttribute columnNew) {
-        return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                List<String> sqls = new ArrayList<String>();
-
-                if (columnOriginal.getMaxLength() != columnNew.getMaxLength()) {
-                    sqls.add("ALTER TABLE "
-                            + entity.getFullyQualifiedName()
-                            + " COLUMN "
-                            + columnNew.getName()
-                            + " SET LENGTH "
-                            + columnNew.getMaxLength());
-                }
-
-                return sqls;
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createSetNotNullToDb(DbEntity entity, DbAttribute column) {
-        return new SetNotNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-
-                return Collections.singletonList("ALTER TABLE " + getEntity().getFullyQualifiedName()
-                        + " COLUMN " + getColumn().getName() + " SET NOT NULL");
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createSetAllowNullToDb(DbEntity entity, DbAttribute column) {
-        return new SetAllowNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-
-                return Collections.singletonList("ALTER TABLE " + getEntity().getFullyQualifiedName()
-                        + " COLUMN " + getColumn().getName() + " SET NULL");
-            }
-
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
index adfd6dd..668676f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
@@ -26,7 +26,11 @@ import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
-import org.apache.cayenne.access.types.*;
+import org.apache.cayenne.access.types.ByteType;
+import org.apache.cayenne.access.types.ExtendedType;
+import org.apache.cayenne.access.types.ExtendedTypeFactory;
+import org.apache.cayenne.access.types.ExtendedTypeMap;
+import org.apache.cayenne.access.types.ShortType;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -35,12 +39,20 @@ import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.query.*;
+import org.apache.cayenne.query.BatchQuery;
+import org.apache.cayenne.query.InsertBatchQuery;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLAction;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.UpdateBatchQuery;
 import org.apache.cayenne.resource.ResourceLocator;
 
 import java.lang.reflect.Field;
-import java.sql.*;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -330,9 +342,4 @@ public class OracleAdapter extends JdbcAdapter {
 			return st.wasNull() ? null : i == 0 ? Boolean.FALSE : Boolean.TRUE;
 		}
 	}
-
-	@Override
-	public MergerFactory mergerFactory() {
-		return new OracleMergerFactory();
-	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
deleted file mode 100644
index 7b52185..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*****************************************************************
- *   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.dba.oracle;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.AddColumnToDb;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.merge.MergerToken;
-import org.apache.cayenne.merge.SetAllowNullToDb;
-import org.apache.cayenne.merge.SetColumnTypeToDb;
-import org.apache.cayenne.merge.SetNotNullToDb;
-
-
-public class OracleMergerFactory extends MergerFactory {
-
-    @Override
-    public MergerToken createAddColumnToDb(final DbEntity entity, final DbAttribute column) {
-        return new AddColumnToDb(entity, column) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" ADD ");
-                sqlBuffer.append(context.quotedName(column));
-                sqlBuffer.append(" ");
-            }
-        };
-    }
-    
-    @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            DbAttribute columnOriginal,
-            final DbAttribute columnNew) {
-
-        return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(context.quotedName(columnNew));
-                sqlBuffer.append(" ");
-            }
-        };
-    }
-    
-    @Override
-    public MergerToken createSetAllowNullToDb(DbEntity entity, final DbAttribute column) {
-        return new SetAllowNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuffer sqlBuffer = new StringBuffer();
-
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(adapter.getQuotingStrategy().quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" MODIFY ");
-
-                adapter.createTableAppendColumn(sqlBuffer, column);
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createSetNotNullToDb(DbEntity entity, final DbAttribute column) {
-
-        return new SetNotNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuffer sqlBuffer = new StringBuffer();
-
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(adapter.getQuotingStrategy().quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" MODIFY ");
-
-                adapter.createTableAppendColumn(sqlBuffer, column);
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
index 7df4354..98c9944 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
@@ -39,7 +39,6 @@ import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SelectQuery;
@@ -272,11 +271,6 @@ public class PostgresAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public MergerFactory mergerFactory() {
-		return new PostgresMergerFactory();
-	}
-
-	@Override
 	public boolean supportsCatalogsOnReverseEngineering() {
 		return false;
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
deleted file mode 100644
index 6e5db58..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
- *   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.dba.postgres;
-
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.merge.MergerToken;
-import org.apache.cayenne.merge.SetColumnTypeToDb;
-
-public class PostgresMergerFactory extends MergerFactory {
-
-    @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            DbAttribute columnOriginal,
-            final DbAttribute columnNew) {
-
-        return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy quotingStrategy) {
-                // http://www.postgresql.org/docs/8.2/static/sql-altertable.html
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(quotingStrategy.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(quotingStrategy.quotedName(columnNew));
-                sqlBuffer.append(" TYPE ");
-            }
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
index 537296d..3faec45 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
@@ -31,7 +31,6 @@ import org.apache.cayenne.dba.sybase.SybaseAdapter;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SelectQuery;
@@ -138,9 +137,4 @@ public class SQLServerAdapter extends SybaseAdapter {
 		}
 	}
 
-	@Override
-	public MergerFactory mergerFactory() {
-		return new SQLServerMergerFactory();
-	}
-
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
deleted file mode 100644
index 202f09c..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*****************************************************************
- *   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.dba.sqlserver;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.AddColumnToDb;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.merge.MergerToken;
-import org.apache.cayenne.merge.SetAllowNullToDb;
-import org.apache.cayenne.merge.SetColumnTypeToDb;
-import org.apache.cayenne.merge.SetNotNullToDb;
-
-public class SQLServerMergerFactory extends MergerFactory {
-
-    @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            DbAttribute columnOriginal,
-            final DbAttribute columnNew) {
-
-        return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-                // http://msdn2.microsoft.com/en-us/library/ms190273.aspx
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(context.quotedName(columnNew));
-                sqlBuffer.append(" ");
-            }
-        };
-    }
-
-    @Override
-    public MergerToken createAddColumnToDb(final DbEntity entity, final DbAttribute column) {
-        return new AddColumnToDb(entity, column) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-                // http://msdn2.microsoft.com/en-us/library/ms190273.aspx
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" ADD ");
-                sqlBuffer.append(context.quotedName(column));
-                sqlBuffer.append(" ");
-            }
-        };
-    }
-
-    @Override
-    public MergerToken createSetAllowNullToDb(DbEntity entity, final DbAttribute column) {
-        return new SetAllowNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuffer sqlBuffer = new StringBuffer();
-
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(adapter.getQuotingStrategy().quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" ALTER COLUMN ");
-
-                adapter.createTableAppendColumn(sqlBuffer, column);
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-    @Override
-    public MergerToken createSetNotNullToDb(DbEntity entity, final DbAttribute column) {
-
-        return new SetNotNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuffer sqlBuffer = new StringBuffer();
-
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(adapter.getQuotingStrategy().quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" ALTER COLUMN ");
-
-                adapter.createTableAppendColumn(sqlBuffer, column);
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
index 2b0ca86..073290a 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
@@ -21,7 +21,13 @@ package org.apache.cayenne.dba.sybase;
 
 import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
-import org.apache.cayenne.access.types.*;
+import org.apache.cayenne.access.types.ByteArrayType;
+import org.apache.cayenne.access.types.ByteType;
+import org.apache.cayenne.access.types.CharType;
+import org.apache.cayenne.access.types.ExtendedType;
+import org.apache.cayenne.access.types.ExtendedTypeFactory;
+import org.apache.cayenne.access.types.ExtendedTypeMap;
+import org.apache.cayenne.access.types.ShortType;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.dba.DefaultQuotingStrategy;
@@ -29,7 +35,6 @@ import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.dba.PkGenerator;
 import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.resource.ResourceLocator;
 
 import java.sql.PreparedStatement;
@@ -122,9 +127,4 @@ public class SybaseAdapter extends JdbcAdapter {
             super.bindParameter(statement, binding);
         }
     }
-
-    @Override
-    public MergerFactory mergerFactory() {
-        return new SybaseMergerFactory();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
deleted file mode 100644
index b3d204f..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*****************************************************************
- *   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.dba.sybase;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.AddColumnToDb;
-import org.apache.cayenne.merge.DropColumnToDb;
-import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.merge.MergerToken;
-import org.apache.cayenne.merge.SetAllowNullToDb;
-import org.apache.cayenne.merge.SetColumnTypeToDb;
-import org.apache.cayenne.merge.SetNotNullToDb;
-
-/**
- * @since 3.0
- */
-public class SybaseMergerFactory extends MergerFactory {
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public MergerToken createAddColumnToDb(DbEntity entity, final DbAttribute column) {
-        return new AddColumnToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-
-                StringBuffer sqlBuffer = new StringBuffer();
-                QuotingStrategy context = adapter.getQuotingStrategy();
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" ADD ");
-                boolean magnatory = column.isMandatory();
-                column.setMandatory(false);
-                adapter.createTableAppendColumn(sqlBuffer, column);
-                if(magnatory){
-                    column.setMandatory(magnatory);
-                }
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public MergerToken createDropColumnToDb(DbEntity entity, DbAttribute column) {
-        return new DropColumnToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuilder sqlBuffer = new StringBuilder();
-                QuotingStrategy context = adapter.getQuotingStrategy();
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
-                sqlBuffer.append(" DROP ");
-                sqlBuffer.append(context.quotedName(getColumn()));
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public MergerToken createSetNotNullToDb(DbEntity entity, DbAttribute column) {
-        return new SetNotNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-
-                StringBuffer sqlBuffer = createStringQuery(
-                        adapter,
-                        getEntity(),
-                        getColumn());
-
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-
-        };
-    }
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public MergerToken createSetAllowNullToDb(DbEntity entity, DbAttribute column) {
-        return new SetAllowNullToDb(entity, column) {
-
-            @Override
-            public List<String> createSql(DbAdapter adapter) {
-                StringBuffer sqlBuffer = createStringQuery(
-                        adapter,
-                        getEntity(),
-                        getColumn());
-                return Collections.singletonList(sqlBuffer.toString());
-            }
-        };
-    }
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            DbAttribute columnOriginal,
-            final DbAttribute columnNew) {
-
-        return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
-
-            @Override
-            protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-                // http://dev.mysql.com/tech-resources/articles/mysql-cluster-50.html
-                sqlBuffer.append("ALTER TABLE ");
-                sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-                sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(context.quotedName(columnNew));
-                sqlBuffer.append(" ");
-            }
-
-        };
-    }
-
-    private static StringBuffer createStringQuery(
-            DbAdapter adapter,
-            DbEntity entity,
-            DbAttribute column) {
-        StringBuffer sqlBuffer = new StringBuffer();
-        QuotingStrategy context = adapter.getQuotingStrategy();
-        sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(context.quotedFullyQualifiedName(entity));
-        sqlBuffer.append(" MODIFY ");
-        adapter.createTableAppendColumn(sqlBuffer, column);
-
-        return sqlBuffer;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
deleted file mode 100644
index d7c4d9d..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*****************************************************************
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.dbimport;
-
-import org.apache.cayenne.access.loader.filters.LegacyFilterConfigBridge;
-import org.apache.cayenne.access.loader.filters.CatalogFilter;
-import org.apache.cayenne.access.loader.filters.IncludeTableFilter;
-import org.apache.cayenne.access.loader.filters.SchemaFilter;
-import org.apache.cayenne.access.loader.filters.TableFilter;
-import org.apache.cayenne.access.loader.filters.FiltersConfig;
-import org.apache.cayenne.access.loader.filters.PatternFilter;
-
-import java.util.*;
-import java.util.regex.Pattern;
-
-import static org.apache.commons.lang.StringUtils.isBlank;
-
-/**
- * @since 4.0.
- */
-public final class FiltersConfigBuilder {
-
-    private final ReverseEngineering engineering;
-
-    public FiltersConfigBuilder(ReverseEngineering engineering) {
-        this.engineering = engineering;
-    }
-
-    public FiltersConfig filtersConfig() {
-        compact();
-
-        return new FiltersConfig(transformCatalogs(engineering.getCatalogs()));
-    }
-
-    private CatalogFilter[] transformCatalogs(Collection<Catalog> catalogs) {
-        CatalogFilter[] catalogFilters = new CatalogFilter[catalogs.size()];
-        int i = 0;
-        for (Catalog catalog : catalogs) {
-            catalogFilters[i] = new CatalogFilter(catalog.getName(), transformSchemas(catalog.getSchemas()));
-            i++;
-        }
-
-        return catalogFilters;
-    }
-
-    private SchemaFilter[] transformSchemas(Collection<Schema> schemas) {
-        SchemaFilter[] schemaFilters = new SchemaFilter[schemas.size()];
-        int i = 0;
-        for (Schema schema : schemas) {
-            schemaFilters[i] = new SchemaFilter(schema.getName(),
-                    new TableFilter(transformIncludeTable(schema.getIncludeTables()),
-                            transformExcludeTable(schema.getExcludeTables())),
-                    transform(schema.getIncludeProcedures(), schema.getExcludeProcedures()));
-            i++;
-        }
-
-        return schemaFilters;
-    }
-
-    private SortedSet<Pattern> transformExcludeTable(Collection<ExcludeTable> excludeTables) {
-        SortedSet<Pattern> res = new TreeSet<Pattern>(PatternFilter.PATTERN_COMPARATOR);
-        for (ExcludeTable exclude : excludeTables) {
-            res.add(PatternFilter.pattern(exclude.getPattern()));
-        }
-        return res;
-    }
-
-    private SortedSet<IncludeTableFilter> transformIncludeTable(Collection<IncludeTable> includeTables) {
-        SortedSet<IncludeTableFilter> includeTableFilters = new TreeSet<IncludeTableFilter>();
-        for (IncludeTable includeTable : includeTables) {
-            includeTableFilters.add(new IncludeTableFilter(includeTable.getPattern(),
-                    transform(includeTable.getIncludeColumns(), includeTable.getExcludeColumns())));
-        }
-
-        return includeTableFilters;
-    }
-
-    private PatternFilter transform(Collection<? extends PatternParam> include,
-                                    Collection<? extends PatternParam> exclude) {
-        PatternFilter filter = new PatternFilter();
-
-        for (PatternParam patternParam : include) {
-            filter.include(patternParam.getPattern());
-        }
-
-        for (PatternParam patternParam : exclude) {
-            filter.exclude(patternParam.getPattern());
-        }
-
-        return filter;
-
-    }
-
-    /**
-     * Goal of this method transform ReverseEngineering config into more regular form
-     * From
-     *      ReverseEngineering
-     *          Catalog
-     *              Schema
-     *                  IncludeTable
-     *                      IncludeColumn
-     *                      ExcludeColumn
-     *                  ExcludeTable
-     *                  IncludeProcedures
-     *                  ExcludeProcedures
-     *                  IncludeColumn
-     *                  ExcludeColumn
-     *              IncludeTable
-     *                  IncludeColumn
-     *                  ExcludeColumn
-     *              ExcludeTable
-     *              IncludeProcedures
-     *              ExcludeProcedures
-     *              IncludeColumn
-     *              ExcludeColumn
-     *          Schema
-     *              IncludeTable
-     *                  IncludeColumn
-     *                  ExcludeColumn
-     *              ExcludeTable
-     *              IncludeProcedures
-     *              ExcludeProcedures
-     *              IncludeColumn
-     *              ExcludeColumn
-     *          IncludeTable
-     *              IncludeColumn
-     *              ExcludeColumn
-     *          ExcludeTable
-     *          IncludeProcedures
-     *          ExcludeProcedures
-     *          IncludeColumn
-     *          ExcludeColumn
-     *
-     * Into
-     *      ReverseEngineering
-     *          Catalog
-     *              Schema
-     *                  IncludeTable
-     *                      IncludeColumn
-     *                      ExcludeColumn
-     *                  ExcludeTable
-     *                  IncludeProcedures
-     *                  ExcludeProcedures
-     *
-     *
-     * */
-    public void compact() {
-        addEmptyElements();
-
-        compactColumnFilters();
-        compactTableFilter();
-        compactProcedureFilter();
-        compactSchemas();
-    }
-
-    private void compactSchemas() {
-        for (Catalog catalog : engineering.getCatalogs()) {
-            catalog.getSchemas().addAll(engineering.getSchemas());
-        }
-        engineering.setSchemas(null);
-    }
-
-    private void compactProcedureFilter() {
-        Collection<IncludeProcedure> engIncludeProcedures = engineering.getIncludeProcedures();
-        Collection<ExcludeProcedure> engExcludeProcedures = engineering.getExcludeProcedures();
-
-        engineering.setIncludeProcedures(null);
-        engineering.setExcludeProcedures(null);
-
-        for (Catalog catalog : engineering.getCatalogs()) {
-            Collection<IncludeProcedure> catalogIncludeProcedures = catalog.getIncludeProcedures();
-            Collection<ExcludeProcedure> catalogExcludeProcedures = catalog.getExcludeProcedures();
-
-            catalog.setIncludeProcedures(null);
-            catalog.setExcludeProcedures(null);
-
-            for (Schema schema : catalog.getSchemas()) {
-                if (engIncludeProcedures != null) {
-                    schema.getIncludeProcedures().addAll(engIncludeProcedures);
-                    schema.getIncludeProcedures().addAll(catalogIncludeProcedures);
-                }
-                if (engExcludeProcedures != null) {
-                    schema.getExcludeProcedures().addAll(engExcludeProcedures);
-                    schema.getExcludeProcedures().addAll(catalogExcludeProcedures);
-                }
-            }
-        }
-
-        for (Schema schema : engineering.getSchemas()) {
-            schema.getIncludeProcedures().addAll(engIncludeProcedures);
-            schema.getExcludeProcedures().addAll(engExcludeProcedures);
-        }
-    }
-
-    private void compactTableFilter() {
-        Collection<IncludeTable> engIncludeTables = engineering.getIncludeTables();
-        Collection<ExcludeTable> engExcludeTables = engineering.getExcludeTables();
-
-        engineering.setIncludeTables(null);
-        engineering.setExcludeTables(null);
-
-        for (Catalog catalog : engineering.getCatalogs()) {
-            Collection<IncludeTable> catalogIncludeTables = catalog.getIncludeTables();
-            Collection<ExcludeTable> catalogExcludeTables = catalog.getExcludeTables();
-
-            catalog.setIncludeTables(null);
-            catalog.setExcludeTables(null);
-
-            for (Schema schema : catalog.getSchemas()) {
-                if (engIncludeTables != null) {
-                    schema.getIncludeTables().addAll(engIncludeTables);
-                    schema.getIncludeTables().addAll(catalogIncludeTables);
-                }
-                if (engExcludeTables != null) {
-                    schema.getExcludeTables().addAll(engExcludeTables);
-                    schema.getExcludeTables().addAll(catalogExcludeTables);
-                }
-            }
-        }
-
-        for (Schema schema : engineering.getSchemas()) {
-            schema.getIncludeTables().addAll(engIncludeTables);
-            schema.getExcludeTables().addAll(engExcludeTables);
-        }
-    }
-
-    private void compactColumnFilters() {
-        Collection<IncludeColumn> engIncludeColumns = engineering.getIncludeColumns();
-        Collection<ExcludeColumn> engExcludeColumns = engineering.getExcludeColumns();
-
-        engineering.setIncludeColumns(null);
-        engineering.setExcludeColumns(null);
-
-        for (Catalog catalog : engineering.getCatalogs()) {
-            Collection<IncludeColumn> catalogIncludeColumns = catalog.getIncludeColumns();
-            Collection<ExcludeColumn> catalogExcludeColumns = catalog.getExcludeColumns();
-
-            catalog.setIncludeColumns(null);
-            catalog.setExcludeColumns(null);
-
-            for (Schema schema : catalog.getSchemas()) {
-                Collection<IncludeColumn> schemaIncludeColumns = schema.getIncludeColumns();
-                Collection<ExcludeColumn> schemaExcludeColumns = schema.getExcludeColumns();
-
-                schema.setIncludeColumns(null);
-                schema.setExcludeColumns(null);
-
-                if (schema != null) {
-                    for (IncludeTable includeTable : schema.getIncludeTables()) {
-                        if (engIncludeColumns != null) {
-                            includeTable.getIncludeColumns().addAll(engIncludeColumns);
-                            includeTable.getIncludeColumns().addAll(catalogIncludeColumns);
-                            includeTable.getIncludeColumns().addAll(schemaIncludeColumns);
-                        }
-                        if (engExcludeColumns != null) {
-                            includeTable.getExcludeColumns().addAll(engExcludeColumns);
-                            includeTable.getExcludeColumns().addAll(catalogExcludeColumns);
-                            includeTable.getExcludeColumns().addAll(schemaExcludeColumns);
-                        }
-                    }
-                }
-            }
-
-            if (catalog.getIncludeTables() != null) {
-                for (IncludeTable includeTable : catalog.getIncludeTables()) {
-                    includeTable.getIncludeColumns().addAll(engIncludeColumns);
-                    includeTable.getIncludeColumns().addAll(catalogIncludeColumns);
-
-                    includeTable.getExcludeColumns().addAll(engExcludeColumns);
-                    includeTable.getExcludeColumns().addAll(catalogExcludeColumns);
-                }
-            }
-        }
-
-        for (Schema schema : engineering.getSchemas()) {
-            Collection<IncludeColumn> schemaIncludeColumns = schema.getIncludeColumns();
-            Collection<ExcludeColumn> schemaExcludeColumns = schema.getExcludeColumns();
-
-            schema.setIncludeColumns(null);
-            schema.setExcludeColumns(null);
-
-            for (IncludeTable includeTable : schema.getIncludeTables()) {
-                includeTable.getIncludeColumns().addAll(engIncludeColumns);
-                includeTable.getIncludeColumns().addAll(schemaIncludeColumns);
-
-                includeTable.getExcludeColumns().addAll(engExcludeColumns);
-                includeTable.getExcludeColumns().addAll(schemaExcludeColumns);
-            }
-        }
-
-        if (engineering.getIncludeTables() != null) {
-            for (IncludeTable includeTable : engineering.getIncludeTables()) {
-                includeTable.getIncludeColumns().addAll(engIncludeColumns);
-                includeTable.getExcludeColumns().addAll(engExcludeColumns);
-            }
-        }
-    }
-
-    private void addEmptyElements() {
-        if (engineering.getCatalogs().isEmpty()) {
-            engineering.addCatalog(new Catalog());
-        }
-
-        for (Catalog catalog : engineering.getCatalogs()) {
-            if (catalog.getSchemas().isEmpty()
-                    && engineering.getSchemas().isEmpty()) {
-                catalog.addSchema(new Schema());
-            }
-
-            for (Schema schema : catalog.getSchemas()) {
-                if (schema.getIncludeTables().isEmpty()
-                        && catalog.getIncludeTables().isEmpty()
-                        && engineering.getIncludeTables().isEmpty()) {
-
-                    schema.addIncludeTable(new IncludeTable());
-                }
-            }
-        }
-
-        if (engineering.getSchemas() == null) {
-            engineering.setSchemas(new LinkedList<Schema>());
-        }
-
-        for (Schema schema : engineering.getSchemas()) {
-            if (schema.getIncludeTables().isEmpty()
-                    && engineering.getIncludeTables().isEmpty()) {
-
-                schema.addIncludeTable(new IncludeTable());
-            }
-        }
-    }
-
-    public FiltersConfigBuilder add(LegacyFilterConfigBridge build) {
-        if (!isBlank(build.catalog())) {
-            engineering.addCatalog(new Catalog(build.catalog()));
-        }
-
-        if (!isBlank(build.schema())) {
-            engineering.addSchema(new Schema(build.schema()));
-        }
-
-        if (!isBlank(build.getIncludeTableFilters())) {
-            engineering.addIncludeTable(new IncludeTable(build.getIncludeTableFilters()));
-        }
-        if (!isBlank(build.getExcludeTableFilters())) {
-            engineering.addExcludeTable(new ExcludeTable(build.getExcludeTableFilters()));
-        }
-
-        if (!isBlank(build.getIncludeColumnFilters())) {
-            engineering.addIncludeColumn(new IncludeColumn(build.getIncludeColumnFilters()));
-        }
-        if (!isBlank(build.getExcludeColumnFilters())) {
-            engineering.addExcludeColumn(new ExcludeColumn(build.getExcludeColumnFilters()));
-        }
-
-        if (build.isLoadProcedures()) {
-            if (!isBlank(build.getIncludeProceduresFilters())) {
-                engineering.addIncludeProcedure(new IncludeProcedure(build.getIncludeProceduresFilters()));
-            }
-            if (!isBlank(build.getExcludeProceduresFilters())) {
-                engineering.addExcludeProcedure(new ExcludeProcedure(build.getExcludeProceduresFilters()));
-            }
-        }
-
-        return this;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
deleted file mode 100644
index 7430ba3..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.validation.SimpleValidationFailure;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
-/**
- * Common abstract superclass for all {@link MergerToken}s going from the model
- * to the database.
- */
-public abstract class AbstractToDbToken implements MergerToken, Comparable<MergerToken> {
-
-	private final String tokenName;
-
-	protected AbstractToDbToken(String tokenName) {
-		this.tokenName = tokenName;
-	}
-
-	@Override
-	public final String getTokenName() {
-		return tokenName;
-	}
-
-	@Override
-	public final MergeDirection getDirection() {
-		return MergeDirection.TO_DB;
-	}
-
-	@Override
-	public void execute(MergerContext mergerContext) {
-		for (String sql : createSql(mergerContext.getDataNode().getAdapter())) {
-			executeSql(mergerContext, sql);
-		}
-	}
-
-	protected void executeSql(MergerContext mergerContext, String sql) {
-		JdbcEventLogger logger = mergerContext.getDataNode().getJdbcEventLogger();
-		logger.log(sql);
-
-		try (Connection conn = mergerContext.getDataNode().getDataSource().getConnection();) {
-
-			try (Statement st = conn.createStatement();) {
-				st.execute(sql);
-			}
-		} catch (SQLException e) {
-			mergerContext.getValidationResult().addFailure(new SimpleValidationFailure(sql, e.getMessage()));
-			logger.logQueryError(e);
-		}
-	}
-
-	@Override
-	public String toString() {
-		return getTokenName() + ' ' + getTokenValue() + ' ' + getDirection();
-	}
-
-	public abstract List<String> createSql(DbAdapter adapter);
-
-	abstract static class Entity extends AbstractToDbToken {
-
-		private DbEntity entity;
-
-		public Entity(String tokenName, DbEntity entity) {
-			super(tokenName);
-			this.entity = entity;
-		}
-
-		public DbEntity getEntity() {
-			return entity;
-		}
-
-		public String getTokenValue() {
-			return getEntity().getName();
-		}
-
-		public int compareTo(MergerToken o) {
-			// default order as tokens are created
-			return 0;
-		}
-
-	}
-
-	abstract static class EntityAndColumn extends Entity {
-
-		private DbAttribute column;
-
-		public EntityAndColumn(String tokenName, DbEntity entity, DbAttribute column) {
-			super(tokenName, entity);
-			this.column = column;
-		}
-
-		public DbAttribute getColumn() {
-			return column;
-		}
-
-		@Override
-		public String getTokenValue() {
-			return getEntity().getName() + "." + getColumn().getName();
-		}
-
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
deleted file mode 100644
index 49b680b..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-
-/**
- * Common abstract superclass for all {@link MergerToken}s going from the database to the
- * model.
- * 
- */
-public abstract class AbstractToModelToken implements MergerToken {
-
-    private final String tokenName;
-
-    protected AbstractToModelToken(String tokenName) {
-        this.tokenName = tokenName;
-    }
-
-    @Override
-    public final String getTokenName() {
-        return tokenName;
-    }
-
-    public final MergeDirection getDirection() {
-        return MergeDirection.TO_MODEL;
-    }
-
-    protected static void remove(ModelMergeDelegate mergerContext, DbRelationship rel, boolean reverse) {
-        if (rel == null) {
-            return;
-        }
-        if (reverse) {
-            remove(mergerContext, rel.getReverseRelationship(), false);
-        }
-
-        DbEntity dbEntity = rel.getSourceEntity();
-        for (ObjEntity objEntity : dbEntity.mappedObjEntities()) {
-            remove(mergerContext, objEntity.getRelationshipForDbRelationship(rel), true);
-        }
-        
-        rel.getSourceEntity().removeRelationship(rel.getName());
-        mergerContext.dbRelationshipRemoved(rel);
-    }
-
-    protected static void remove(ModelMergeDelegate mergerContext, ObjRelationship rel, boolean reverse) {
-        if (rel == null) {
-            return;
-        }
-        if (reverse) {
-            remove(mergerContext, rel.getReverseRelationship(), false);
-        }
-        rel.getSourceEntity().removeRelationship(rel.getName());
-        mergerContext.objRelationshipRemoved(rel);
-    }
-
-    @Override
-    public String toString() {
-        return getTokenName() + ' ' + getTokenValue() + ' ' + getDirection();
-    }
-    
-    abstract static class Entity extends AbstractToModelToken {
-        
-        private final DbEntity entity;
-
-        protected Entity(String tokenName, DbEntity entity) {
-            super(tokenName);
-            this.entity = entity;
-        }
-
-        public DbEntity getEntity() {
-            return entity;
-        }
-        
-        public String getTokenValue() {
-            return getEntity().getName();
-        }
-        
-    }
-    
-    abstract static class EntityAndColumn extends Entity {
-        
-        private final DbAttribute column;
-        
-        protected EntityAndColumn(String tokenName, DbEntity entity, DbAttribute column) {
-            super(tokenName, entity);
-            this.column = column;
-        }
-
-        public DbAttribute getColumn() {
-            return column;
-        }
-
-        @Override
-        public String getTokenValue() {
-            return getEntity().getName() + "." + getColumn().getName();
-        }
-        
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
deleted file mode 100644
index 77b7486..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.merge;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-
-public class AddColumnToDb extends AbstractToDbToken.EntityAndColumn {
-
-    public AddColumnToDb(DbEntity entity, DbAttribute column) {
-        super("Add Column", entity, column);
-    }
-
-    /**
-     * append the part of the token before the actual column data type
-     */
-    protected void appendPrefix(StringBuffer sqlBuffer, QuotingStrategy context) {
-
-        sqlBuffer.append("ALTER TABLE ");
-        sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
-        sqlBuffer.append(" ADD COLUMN ");
-        sqlBuffer.append(context.quotedName(getColumn()));
-        sqlBuffer.append(" ");
-    }
-
-    @Override
-    public List<String> createSql(DbAdapter adapter) {
-        StringBuffer sqlBuffer = new StringBuffer();
-        QuotingStrategy context = adapter.getQuotingStrategy();
-        appendPrefix(sqlBuffer, context);
-
-        sqlBuffer.append(JdbcAdapter.getType(adapter, getColumn()));
-        sqlBuffer.append(JdbcAdapter.sizeAndPrecision(adapter, getColumn()));
-
-        return Collections.singletonList(sqlBuffer.toString());
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropColumnToModel(getEntity(), getColumn());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
deleted file mode 100644
index 9e96928..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.util.EntityMergeSupport;
-
-/**
- * A {@link MergerToken} to add a {@link DbAttribute} to a {@link DbEntity}. The
- * {@link EntityMergeSupport} will be used to update the mapped {@link ObjEntity}
- * 
- */
-public class AddColumnToModel extends AbstractToModelToken.EntityAndColumn {
-
-    public AddColumnToModel(DbEntity entity, DbAttribute column) {
-        super("Add Column", entity, column);
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropColumnToDb(getEntity(), getColumn());
-    }
-
-    public void execute(MergerContext mergerContext) {
-        getEntity().addAttribute(getColumn());
-
-        // TODO: use EntityMergeSupport from DbImportConfiguration... otherwise we are ignoring a bunch of
-        // important settings
-
-        EntityMergeSupport entityMergeSupport =  new EntityMergeSupport(mergerContext.getDataMap());
-        for(ObjEntity e : getEntity().mappedObjEntities()) {
-            entityMergeSupport.synchronizeOnDbAttributeAdded(e, getColumn());
-        }
-
-        mergerContext.getModelMergeDelegate().dbAttributeAdded(getColumn());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
deleted file mode 100644
index dbd65d8..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.access.DbGenerator;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-
-public class AddRelationshipToDb extends AbstractToDbToken.Entity {
-
-    private DbRelationship rel;
-
-    public AddRelationshipToDb(DbEntity entity, DbRelationship rel) {
-        super("Add foreign key", entity);
-        this.rel = rel;
-    }
-
-    /**
-     * @see DbGenerator#createConstraintsQueries(org.apache.cayenne.map.DbEntity)
-     */
-    @Override
-    public List<String> createSql(DbAdapter adapter) {
-        // TODO: skip FK to a different DB
-
-        if (this.shouldGenerateFkConstraint()) {
-            String fksql = adapter.createFkConstraint(rel);
-            if (fksql != null) {
-                return Collections.singletonList(fksql);
-            }
-        }
-        return Collections.emptyList();
-    }
-
-    public boolean shouldGenerateFkConstraint() {
-        return !rel.isToMany()
-                && rel.isToPK() // TODO it is not necessary primary key it can be unique index
-                && !rel.isToDependentPK();
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropRelationshipToModel(getEntity(), rel);
-    }
-
-    @Override
-    public String getTokenValue() {
-        if (this.shouldGenerateFkConstraint()) {
-            return rel.getSourceEntity().getName() + "->" + rel.getTargetEntityName();
-        } else {
-            return "Skip. No sql representation.";
-        }
-    }
-    
-    public DbRelationship getRelationship() {
-        return rel;
-    }
-    
-    @Override
-    public int compareTo(MergerToken o) {
-        // add all AddRelationshipToDb to the end.
-        if (o instanceof AddRelationshipToDb) {
-            return super.compareTo(o);
-        }
-        return 1;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
deleted file mode 100644
index 42d7329..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.util.EntityMergeSupport;
-
-public class AddRelationshipToModel extends AbstractToModelToken.Entity {
-
-    public static final String COMMA_SEPARATOR = ", ";
-    public static final int COMMA_SEPARATOR_LENGTH = COMMA_SEPARATOR.length();
-    private DbRelationship rel;
-
-    public AddRelationshipToModel(DbEntity entity, DbRelationship rel) {
-        super("Add Relationship", entity);
-        this.rel = rel;
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropRelationshipToDb(getEntity(), rel);
-    }
-
-    public void execute(MergerContext mergerContext) {
-        getEntity().addRelationship(rel);
-        // TODO: add reverse relationship as well if it does not exist
-
-        // TODO: use EntityMergeSupport from DbImportConfiguration... otherwise we are ignoring a bunch of
-        // important settings
-
-        EntityMergeSupport entityMergeSupport =  new EntityMergeSupport(mergerContext.getDataMap());
-        for(ObjEntity e : getEntity().mappedObjEntities()) {
-            entityMergeSupport.synchronizeOnDbRelationshipAdded(e, rel);
-        }
-
-        mergerContext.getModelMergeDelegate().dbRelationshipAdded(rel);
-    }
-
-    @Override
-    public String getTokenValue() {
-        String attributes = "";
-        if (rel.getJoins().size() == 1) {
-            attributes = rel.getJoins().get(0).getTargetName();
-        } else {
-            for (DbJoin dbJoin : rel.getJoins()) {
-                attributes += dbJoin.getTargetName() + COMMA_SEPARATOR;
-            }
-
-            attributes = "{" + attributes.substring(0, attributes.length() - COMMA_SEPARATOR_LENGTH) + "}";
-        }
-
-        return rel.getName() + " " + rel.getSourceEntity().getName() + "->" + rel.getTargetEntityName() + "." + attributes;
-    }
-
-
-    public static String getTokenValue(DbRelationship rel) {
-        String attributes = "";
-        if (rel.getJoins().size() == 1) {
-            attributes = rel.getJoins().get(0).getTargetName();
-        } else {
-            for (DbJoin dbJoin : rel.getJoins()) {
-                attributes += dbJoin.getTargetName() + COMMA_SEPARATOR;
-            }
-
-            attributes = "{" + attributes.substring(0, attributes.length() - COMMA_SEPARATOR_LENGTH) + "}";
-        }
-
-        return rel.getName() + " " + rel.getSourceEntity().getName() + "->" + rel.getTargetEntityName() + "." + attributes;
-    }
-
-    public DbRelationship getRelationship() {
-        return rel;
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToDb.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToDb.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToDb.java
deleted file mode 100644
index 077ec74..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToDb.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.validation.SimpleValidationFailure;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class CreateTableToDb extends AbstractToDbToken.Entity {
-
-    public CreateTableToDb(DbEntity entity) {
-        super("Create Table", entity);
-    }
-
-    @Override
-    public List<String> createSql(DbAdapter adapter) {
-        List<String> sqls = new ArrayList<String>();
-        sqls.addAll(adapter.getPkGenerator().createAutoPkStatements(
-                Collections.singletonList(getEntity())));
-        sqls.add(adapter.createTable(getEntity()));
-        return sqls;
-    }
-
-    @Override
-    public void execute(MergerContext mergerContext) {
-        try {
-            DataNode node = mergerContext.getDataNode();
-            DbAdapter adapter = node.getAdapter();
-            adapter.getPkGenerator().createAutoPk(
-                    node,
-                    Collections.singletonList(getEntity()));
-            executeSql(mergerContext, adapter.createTable(getEntity()));
-        }
-        catch (Exception e) {
-            mergerContext.getValidationResult().addFailure(
-                    new SimpleValidationFailure(this, e.getMessage()));
-        }
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropTableToModel(getEntity());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
deleted file mode 100644
index cdd6009..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*****************************************************************
- *   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.merge;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.naming.NameConverter;
-import org.apache.cayenne.util.EntityMergeSupport;
-
-/**
- * A {@link MergerToken} to add a {@link DbEntity} to a {@link DataMap}
- * 
- */
-public class CreateTableToModel extends AbstractToModelToken.Entity {
-
-    /**
-     * className if {@link ObjEntity} should be generated with a
-     *  special class name.
-     * Setting this to <code>null</code>, because by default class name should be generated 
-     */
-    private String objEntityClassName = null; //CayenneDataObject.class.getName();
-
-    public CreateTableToModel(DbEntity entity) {
-        super("Create Table", entity);
-    }
-
-    /**
-     * Set the {@link ObjEntity} className if {@link ObjEntity} should be generated with a
-     * special class name. Set to null if the {@link ObjEntity} should be created with a
-     * name based on {@link DataMap#getDefaultPackage()} and {@link ObjEntity#getName()}
-     * <p>
-     * The default value is <code>null</code>
-     */
-    public void setObjEntityClassName(String n) {
-        objEntityClassName = n;
-    }
-
-    public void execute(MergerContext mergerContext) {
-        DataMap map = mergerContext.getDataMap();
-        map.addDbEntity(getEntity());
-
-        // create a ObjEntity
-        String objEntityName = NameConverter.underscoredToJava(getEntity().getName(), true);
-        // this loop will terminate even if no valid name is found
-        // to prevent loader from looping forever (though such case is very unlikely)
-        String baseName = objEntityName;
-        for (int i = 1; i < 1000 && map.getObjEntity(objEntityName) != null; i++) {
-            objEntityName = baseName + i;
-        }
-
-        ObjEntity objEntity = new ObjEntity(objEntityName);
-        objEntity.setDbEntity(getEntity());
-
-        // try to find a class name for the ObjEntity
-        String className = objEntityClassName;
-        if (className == null) {
-            // we should generate a className based on the objEntityName
-            className = map.getNameWithDefaultPackage(objEntityName);
-        }
-
-        objEntity.setClassName(className);
-        objEntity.setSuperClassName(map.getDefaultSuperclass());
-        
-        if (map.isClientSupported()) {
-            objEntity.setClientClassName(map.getNameWithDefaultClientPackage(objEntity.getName()));
-            objEntity.setClientSuperClassName(map.getDefaultClientSuperclass());
-        }
-        
-        map.addObjEntity(objEntity);
-
-        // presumably there are no other ObjEntities pointing to this DbEntity, so syncing just this one...
-
-        // TODO: use EntityMergeSupport from DbImportConfiguration... otherwise we are ignoring a bunch of
-        // important settings
-        new EntityMergeSupport(map).synchronizeWithDbEntity(objEntity);
-
-        mergerContext.getModelMergeDelegate().dbEntityAdded(getEntity());
-        mergerContext.getModelMergeDelegate().objEntityAdded(objEntity);
-    }
-
-    public MergerToken createReverse(MergerFactory factory) {
-        return factory.createDropTableToDb(getEntity());
-    }
-
-}


Mime
View raw message