public class GenericDbmsHelper extends Object implements DbmsHelper
| Modifier and Type | Field and Description |
|---|---|
protected org.eclipse.persistence.platform.database.DatabasePlatform |
databasePlatform |
| Constructor and Description |
|---|
GenericDbmsHelper(org.eclipse.persistence.platform.database.DatabasePlatform databasePlatform) |
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.persistence.tools.schemaframework.FieldDefinition |
convertToFieldDefinition(DBAccessor.DBColumnInfo columnInfo) |
org.eclipse.persistence.internal.sessions.AbstractSession |
createStubAbstractSessionFromPlatform(org.eclipse.persistence.platform.database.DatabasePlatform databasePlatform) |
String |
getAddColumnStatement(String tableName,
DBAccessor.DBColumnInfo columnInfo) |
String |
getAddForeignKeyStatement(String tableName,
String constraintName,
List<String> keyColumns,
String referenceTableName,
List<String> referenceColumns,
boolean shouldCascadeOnDelete) |
String |
getAddPrimaryKeyConstraintStatement(String tableName,
String constraintName,
String... columnName)
Generate alter table statement to add primary key index
|
String |
getAddUniqueConstraintStatement(String tableName,
String constraintName,
String... columnNames)
Generate alter table statement to add unique constraint
|
String |
getAlterColumnStatement(String tableName,
DBAccessor.DBColumnInfo columnInfo)
Generate alter column statement
|
String |
getColumnUpdateStatementWhereColumnIsNull(String tableName,
String setColumnName,
String conditionColumnName)
Generating update SQL statement for
DBAccessor.executePreparedUpdate(java.lang.String, java.lang.Object...) |
String |
getCopyColumnToAnotherTableStatement(String sourceTable,
String sourceColumnName,
String sourceIDColumnName,
String targetTable,
String targetColumnName,
String targetIDColumnName)
Get's the
UPDATE statement for sourceTable for copy column from targetTable by matching
table keys sourceIDColumnName and targetIDColumnName |
String |
getCopyColumnToAnotherTableStatement(String sourceTable,
String sourceColumnName,
String sourceIDColumnName1,
String sourceIDColumnName2,
String sourceIDColumnName3,
String targetTable,
String targetColumnName,
String targetIDColumnName1,
String targetIDColumnName2,
String targetIDColumnName3,
String sourceConditionFieldName,
String condition)
Get's the
UPDATE statement for sourceTable for copy column from targetTable by matching
table keys sourceIDColumnName and targetIDColumnName
and condition sourceConditionFieldName = condition |
String |
getCreateIndexStatement(String indexName,
String tableName,
boolean isUnique,
String... columnNames)
get create index statement
|
String |
getCreateIndexStatement(String indexName,
String tableName,
String... columnNames)
get create index statement
|
String |
getCreateTableStatement(String tableName,
List<DBAccessor.DBColumnInfo> columns,
List<String> primaryKeyColumns)
get create table statement
|
String |
getDropFKConstraintStatement(String tableName,
String constraintName) |
String |
getDropIndexStatement(String indexName,
String tableName)
Gets DROP INDEX statement
|
String |
getDropPrimaryKeyStatement(String tableName,
String constraintName,
boolean cascade) |
String |
getDropSequenceStatement(String sequenceName) |
String |
getDropTableColumnStatement(String tableName,
String columnName) |
String |
getDropTableStatement(String tableName) |
String |
getDropUniqueConstraintStatement(String tableName,
String constraintName) |
String |
getRenameColumnStatement(String tableName,
String oldName,
DBAccessor.DBColumnInfo columnInfo)
Generate rename column statement
|
String |
getRenameColumnStatement(String tableName,
String oldColumnName,
String newColumnName) |
String |
getSetNullableStatement(String tableName,
DBAccessor.DBColumnInfo columnInfo,
boolean nullable)
Gets the
SET NULL or SET NOT NULL statement. |
String |
getTableConstraintsStatement(String databaseName,
String tablename) |
boolean |
isConstraintSupportedAfterNullability()
Gets whether the database platform supports adding contraints after the
NULL constraint. |
String |
quoteObjectName(String name) |
boolean |
supportsColumnTypeChange()
Check if column type can be modified directly
|
StringBuilder |
writeAddPrimaryKeyString(StringBuilder builder,
String constraintName,
String... columnName) |
StringBuilder |
writeAlterTableClause(StringBuilder builder,
String tableName) |
StringBuilder |
writeColumnModifyString(StringBuilder builder,
DBAccessor.DBColumnInfo columnInfo) |
StringBuilder |
writeColumnRenameString(StringBuilder builder,
String oldName,
DBAccessor.DBColumnInfo newColumnInfo) |
StringBuilder |
writeColumnType(StringBuilder builder,
DBAccessor.DBColumnInfo columnInfo) |
Writer |
writeCreateTableStatement(Writer writer,
String tableName,
List<DBAccessor.DBColumnInfo> columns,
List<String> primaryKeyColumns)
Write create table statement to writer
TODO default Value of column not supported
|
StringBuilder |
writeDropPrimaryKeyStatement(StringBuilder builder,
String constraintName,
boolean cascade) |
StringBuilder |
writeDropTableColumnStatement(StringBuilder builder,
String columnName) |
String |
writeGetTableConstraints(String databaseName,
String tableName) |
StringBuilder |
writeSetNullableString(StringBuilder builder,
String tableName,
DBAccessor.DBColumnInfo columnInfo,
boolean nullable) |
protected final org.eclipse.persistence.platform.database.DatabasePlatform databasePlatform
public GenericDbmsHelper(org.eclipse.persistence.platform.database.DatabasePlatform databasePlatform)
public boolean supportsColumnTypeChange()
DbmsHelpersupportsColumnTypeChange in interface DbmsHelperpublic String quoteObjectName(String name)
quoteObjectName in interface DbmsHelperpublic String getRenameColumnStatement(String tableName, String oldName, DBAccessor.DBColumnInfo columnInfo)
DbmsHelpergetRenameColumnStatement in interface DbmsHelpercolumnInfo - definition of new columnpublic String getAlterColumnStatement(String tableName, DBAccessor.DBColumnInfo columnInfo)
DbmsHelpergetAlterColumnStatement in interface DbmsHelperpublic String getSetNullableStatement(String tableName, DBAccessor.DBColumnInfo columnInfo, boolean nullable)
DbmsHelperSET NULL or SET NOT NULL statement.getSetNullableStatement in interface DbmsHelpertableName - the table (not null).columnInfo - the column object to get name and type of column (not null).nullable - true to indicate that the column allows NULL
values, false otherwise.null).public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName, String sourceIDColumnName, String targetTable, String targetColumnName, String targetIDColumnName)
UPDATE statement for sourceTable for copy column from targetTable by matching
table keys sourceIDColumnName and targetIDColumnNamegetCopyColumnToAnotherTableStatement in interface DbmsHelpersourceTable - the source table namesourceColumnName - the source column namesourceIDColumnName - source key id column which would be used to math right rows for targetTabletargetTable - the destination table nametargetColumnName - the destination column nametargetIDColumnName - destination key id column name which should math sourceIDColumnNamepublic String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName, String sourceIDColumnName1, String sourceIDColumnName2, String sourceIDColumnName3, String targetTable, String targetColumnName, String targetIDColumnName1, String targetIDColumnName2, String targetIDColumnName3, String sourceConditionFieldName, String condition)
UPDATE statement for sourceTable for copy column from targetTable by matching
table keys sourceIDColumnName and targetIDColumnName
and condition sourceConditionFieldName = conditiongetCopyColumnToAnotherTableStatement in interface DbmsHelpersourceTable - the source table namesourceColumnName - the source column namesourceIDColumnName1 - source key id column which would be used to math right rows for targetTablesourceIDColumnName2 - source key id column which would be used to math right rows for targetTablesourceIDColumnName3 - source key id column which would be used to math right rows for targetTabletargetTable - the destination table nametargetColumnName - the destination column nametargetIDColumnName1 - destination key id column name which should match sourceIDColumnName1targetIDColumnName2 - destination key id column name which should match sourceIDColumnName1targetIDColumnName3 - destination key id column name which should match sourceIDColumnName1sourceConditionFieldName - source key column name which should match conditioncondition - value which should match sourceConditionFieldNamepublic StringBuilder writeAlterTableClause(StringBuilder builder, String tableName)
public StringBuilder writeColumnModifyString(StringBuilder builder, DBAccessor.DBColumnInfo columnInfo)
public StringBuilder writeColumnRenameString(StringBuilder builder, String oldName, DBAccessor.DBColumnInfo newColumnInfo)
public StringBuilder writeColumnType(StringBuilder builder, DBAccessor.DBColumnInfo columnInfo)
public String writeGetTableConstraints(String databaseName, String tableName)
public StringBuilder writeAddPrimaryKeyString(StringBuilder builder, String constraintName, String... columnName)
public StringBuilder writeSetNullableString(StringBuilder builder, String tableName, DBAccessor.DBColumnInfo columnInfo, boolean nullable)
public StringBuilder writeDropTableColumnStatement(StringBuilder builder, String columnName)
public StringBuilder writeDropPrimaryKeyStatement(StringBuilder builder, String constraintName, boolean cascade)
builder - String Builder passed by referenceconstraintName - Constraint Name used by Postgrescascade - In postgres, can perform a CASCADE delete. In the other DB flavors, this is ignored.public String getDropPrimaryKeyStatement(String tableName, String constraintName, boolean cascade)
getDropPrimaryKeyStatement in interface DbmsHelperpublic String getCreateTableStatement(String tableName, List<DBAccessor.DBColumnInfo> columns, List<String> primaryKeyColumns)
getCreateTableStatement in interface DbmsHelpertableName - columns - primaryKeyColumns - public Writer writeCreateTableStatement(Writer writer, String tableName, List<DBAccessor.DBColumnInfo> columns, List<String> primaryKeyColumns)
public org.eclipse.persistence.tools.schemaframework.FieldDefinition convertToFieldDefinition(DBAccessor.DBColumnInfo columnInfo)
public String getDropUniqueConstraintStatement(String tableName, String constraintName)
getDropUniqueConstraintStatement in interface DbmsHelperpublic String getTableConstraintsStatement(String databaseName, String tablename)
getTableConstraintsStatement in interface DbmsHelperpublic String getCreateIndexStatement(String indexName, String tableName, String... columnNames)
getCreateIndexStatement in interface DbmsHelperindexName - tableName - columnNames - public String getCreateIndexStatement(String indexName, String tableName, boolean isUnique, String... columnNames)
getCreateIndexStatement in interface DbmsHelperindexName - The name of the index to be createdtableName - The database table the index to be created oncolumnNames - The columns included into the indexisUnique - Specifies whether unique index is to be created.public String getColumnUpdateStatementWhereColumnIsNull(String tableName, String setColumnName, String conditionColumnName)
DBAccessor.executePreparedUpdate(java.lang.String, java.lang.Object...)getColumnUpdateStatementWhereColumnIsNull in interface DbmsHelpertableName - name of the tablesetColumnName - column name, value of which need to be setconditionColumnName - column name for the conditionpublic String getDropIndexStatement(String indexName, String tableName)
getDropIndexStatement in interface DbmsHelperpublic String getAddUniqueConstraintStatement(String tableName, String constraintName, String... columnNames)
DbmsHelpergetAddUniqueConstraintStatement in interface DbmsHelpertableName - name of the tableconstraintName - name of the constraintcolumnNames - name of the columnpublic String getAddPrimaryKeyConstraintStatement(String tableName, String constraintName, String... columnName)
DbmsHelpergetAddPrimaryKeyConstraintStatement in interface DbmsHelpertableName - name of the tableconstraintName - name of the primary keycolumnName - name of the columnpublic String getAddForeignKeyStatement(String tableName, String constraintName, List<String> keyColumns, String referenceTableName, List<String> referenceColumns, boolean shouldCascadeOnDelete)
getAddForeignKeyStatement in interface DbmsHelperpublic String getAddColumnStatement(String tableName, DBAccessor.DBColumnInfo columnInfo)
getAddColumnStatement in interface DbmsHelperpublic String getDropTableColumnStatement(String tableName, String columnName)
getDropTableColumnStatement in interface DbmsHelperpublic String getRenameColumnStatement(String tableName, String oldColumnName, String newColumnName)
getRenameColumnStatement in interface DbmsHelperpublic String getDropTableStatement(String tableName)
getDropTableStatement in interface DbmsHelperpublic String getDropFKConstraintStatement(String tableName, String constraintName)
getDropFKConstraintStatement in interface DbmsHelperpublic String getDropSequenceStatement(String sequenceName)
getDropSequenceStatement in interface DbmsHelperpublic org.eclipse.persistence.internal.sessions.AbstractSession createStubAbstractSessionFromPlatform(org.eclipse.persistence.platform.database.DatabasePlatform databasePlatform)
public boolean isConstraintSupportedAfterNullability()
NULL constraint. Some database, such as Oracle, don't allow this.
Unfortunately, EclipsLink hard codes the order of constraints.isConstraintSupportedAfterNullability in interface DbmsHelpertrue if contraints can be added after the NULL
constraint, false otherwise.Copyright © 2022 Apache Software Foundation. All rights reserved.