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()
DbmsHelper
supportsColumnTypeChange
in interface DbmsHelper
public String quoteObjectName(String name)
quoteObjectName
in interface DbmsHelper
public String getRenameColumnStatement(String tableName, String oldName, DBAccessor.DBColumnInfo columnInfo)
DbmsHelper
getRenameColumnStatement
in interface DbmsHelper
columnInfo
- definition of new columnpublic String getAlterColumnStatement(String tableName, DBAccessor.DBColumnInfo columnInfo)
DbmsHelper
getAlterColumnStatement
in interface DbmsHelper
public String getSetNullableStatement(String tableName, DBAccessor.DBColumnInfo columnInfo, boolean nullable)
DbmsHelper
SET NULL
or SET NOT NULL
statement.getSetNullableStatement
in interface DbmsHelper
tableName
- 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 targetIDColumnName
getCopyColumnToAnotherTableStatement
in interface DbmsHelper
sourceTable
- the source table namesourceColumnName
- the source column namesourceIDColumnName
- source key id column which would be used to math right rows for targetTable
targetTable
- the destination table nametargetColumnName
- the destination column nametargetIDColumnName
- destination key id column name which should math sourceIDColumnName
public 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
= condition
getCopyColumnToAnotherTableStatement
in interface DbmsHelper
sourceTable
- the source table namesourceColumnName
- the source column namesourceIDColumnName1
- source key id column which would be used to math right rows for targetTable
sourceIDColumnName2
- source key id column which would be used to math right rows for targetTable
sourceIDColumnName3
- source key id column which would be used to math right rows for targetTable
targetTable
- the destination table nametargetColumnName
- the destination column nametargetIDColumnName1
- destination key id column name which should match sourceIDColumnName1
targetIDColumnName2
- destination key id column name which should match sourceIDColumnName1
targetIDColumnName3
- destination key id column name which should match sourceIDColumnName1
sourceConditionFieldName
- source key column name which should match condition
condition
- value which should match sourceConditionFieldName
public 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 DbmsHelper
public String getCreateTableStatement(String tableName, List<DBAccessor.DBColumnInfo> columns, List<String> primaryKeyColumns)
getCreateTableStatement
in interface DbmsHelper
tableName
- 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 DbmsHelper
public String getTableConstraintsStatement(String databaseName, String tablename)
getTableConstraintsStatement
in interface DbmsHelper
public String getCreateIndexStatement(String indexName, String tableName, String... columnNames)
getCreateIndexStatement
in interface DbmsHelper
indexName
- tableName
- columnNames
- public String getCreateIndexStatement(String indexName, String tableName, boolean isUnique, String... columnNames)
getCreateIndexStatement
in interface DbmsHelper
indexName
- 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 DbmsHelper
tableName
- 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 DbmsHelper
public String getAddUniqueConstraintStatement(String tableName, String constraintName, String... columnNames)
DbmsHelper
getAddUniqueConstraintStatement
in interface DbmsHelper
tableName
- name of the tableconstraintName
- name of the constraintcolumnNames
- name of the columnpublic String getAddPrimaryKeyConstraintStatement(String tableName, String constraintName, String... columnName)
DbmsHelper
getAddPrimaryKeyConstraintStatement
in interface DbmsHelper
tableName
- 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 DbmsHelper
public String getAddColumnStatement(String tableName, DBAccessor.DBColumnInfo columnInfo)
getAddColumnStatement
in interface DbmsHelper
public String getDropTableColumnStatement(String tableName, String columnName)
getDropTableColumnStatement
in interface DbmsHelper
public String getRenameColumnStatement(String tableName, String oldColumnName, String newColumnName)
getRenameColumnStatement
in interface DbmsHelper
public String getDropTableStatement(String tableName)
getDropTableStatement
in interface DbmsHelper
public String getDropFKConstraintStatement(String tableName, String constraintName)
getDropFKConstraintStatement
in interface DbmsHelper
public String getDropSequenceStatement(String sequenceName)
getDropSequenceStatement
in interface DbmsHelper
public 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 DbmsHelper
true
if contraints can be added after the NULL
constraint, false
otherwise.Copyright © 2022 Apache Software Foundation. All rights reserved.