org.jumpmind.db.platform.DmlStatementFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symmetric-db Show documentation
Show all versions of symmetric-db Show documentation
This library is a fork of Apache DdlUtils. DdlUtils is a small, easy-to-use component for working with Database Definition (DDL) files.
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* .
*
* 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.jumpmind.db.platform;
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.mysql.MySqlDmlStatement;
import org.jumpmind.db.platform.oracle.OracleDmlStatement;
import org.jumpmind.db.platform.postgresql.PostgreSqlDmlStatement;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDmlStatement;
import org.jumpmind.db.platform.sqlite.SqliteDmlStatement;
import org.jumpmind.db.sql.DmlStatement;
import org.jumpmind.db.sql.DmlStatement.DmlType;
final public class DmlStatementFactory {
private DmlStatementFactory() {
}
public static DmlStatement createDmlStatement(String databaseName, DmlType dmlType,
Table table, boolean useQuotedIdentifiers) {
return createDmlStatement(databaseName, dmlType, table.getCatalog(), table.getSchema(),
table.getName(), table.getPrimaryKeyColumns(), table.getColumns(), null,
useQuotedIdentifiers);
}
public static DmlStatement createDmlStatement(String databaseName, DmlType dmlType,
String catalogName, String schemaName, String tableName, Column[] keys,
Column[] columns, boolean[] nullKeyValues, boolean useQuotedIdentifiers) {
IDdlBuilder ddlBuilder = DdlBuilderFactory.createDdlBuilder(databaseName);
if (ddlBuilder == null) {
throw new RuntimeException(
"Unable to create DML statements for unknown dialect: " + databaseName);
} else {
ddlBuilder.setDelimitedIdentifierModeOn(useQuotedIdentifiers);
return createDmlStatement(databaseName, dmlType, catalogName, schemaName, tableName, keys,
columns, nullKeyValues, ddlBuilder);
}
}
public static DmlStatement createDmlStatement(String databaseName, DmlType dmlType,
String catalogName, String schemaName, String tableName, Column[] keys,
Column[] columns, boolean[] nullKeyValues, IDdlBuilder ddlBuilder) {
if (DatabaseNamesConstants.ORACLE.equals(databaseName)) {
return new OracleDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
} else if (DatabaseNamesConstants.POSTGRESQL.equals(databaseName)) {
return new PostgreSqlDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
} else if (DatabaseNamesConstants.MYSQL.equals(databaseName)) {
return new MySqlDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
} else if (DatabaseNamesConstants.SQLITE.equals(databaseName)) {
return new SqliteDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
} else if (DatabaseNamesConstants.SQLANYWHERE.equals(databaseName)) {
return new SqlAnywhereDmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
} else {
return new DmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy