| java.lang.Object net.sourceforge.squirrel_sql.fw.dialects.DialectUtils
DialectUtils | public class DialectUtils (Code) | | A simple utility class in which to place common code shared amongst the
dialects. Since the dialects all inherit behavior from specific server
dialects, it is not possible to inherit common behavior from a single base
class. So, this class is where common code is located.
author: manningr |
Method Summary | |
public static String | appendDefaultClause(TableColumnInfo info, StringBuilder buffer) | public static List<String> | createIndexes(ITableInfo ti, ISQLDatabaseMetaData md, List<PrimaryKeyInfo> primaryKeys) | public static String | getAddIndexSQL(String indexName, boolean unique, TableColumnInfo[] columns) | public static String | getAddPrimaryKeySQL(ITableInfo ti, String pkName, TableColumnInfo[] colInfos, boolean appendConstraintName) Returns the SQL for creating a primary key consisting of the specified
colInfos. | public static String | getColumnAddSQL(TableColumnInfo info, HibernateDialect dialect, boolean addDefaultClause, boolean supportsNullQualifier, boolean addNullClause) Returns the SQL statement to use to add a column to the specified table
using the information about the new column specified by info.
Parameters: info - information about the new column such as type, name, etc. Parameters: dialect - the HibernateDialect to use to resolve the type Parameters: addDefaultClause - whether or not the dialect's SQL supports a DEFAULT clause for columns. | public static String | getColumnCommentAlterSQL(String tableName, String columnName, String comment) Returns the SQL statement to use to add a comment to the specified
column of the specified table. | public static String | getColumnCommentAlterSQL(TableColumnInfo info) Returns the SQL statement to use to add a comment to the specified
column of the specified table. | public static String | getColumnDefaultAlterSQL(HibernateDialect dialect, TableColumnInfo info, String alterClause, boolean specifyType, String defaultClause) | public static String | getColumnDropSQL(String tableName, String columnName) | public static String | getColumnDropSQL(String tableName, String columnName, String dropClause, boolean addConstraintClause, String constraintClause) | public static String | getColumnNameAlterSQL(TableColumnInfo from, TableColumnInfo to, String alterClause, String renameToClause) Returns the SQL that is used to change the column name. | public static String | getColumnNullableAlterSQL(TableColumnInfo info, HibernateDialect dialect, String alterClause, boolean specifyType) Returns the SQL used to alter the specified column to allow/disallow null
values.
ALTER TABLE table_name <alterClause> column_name TYPE NULL | NOT NULL
ALTER TABLE table_name <alterClause> column_name NULL | NOT NULL
Parameters: info - the column to modify Parameters: dialect - the HibernateDialect representing the target database. Parameters: alterClause - the alter column clause (e.g. | public static String | getColumnNullableAlterSQL(TableColumnInfo info, boolean nullable, HibernateDialect dialect, String alterClause, boolean specifyType) Returns the SQL used to alter the specified column to allow/disallow null
values.
ALTER TABLE table_name <alterClause> column_name TYPE NULL | NOT NULL
ALTER TABLE table_name <alterClause> column_name NULL | NOT NULL
Parameters: info - the column to modify Parameters: dialect - the HibernateDialect representing the target database. Parameters: alterClause - the alter column clause (e.g. | public static String | getColumnRenameSQL(TableColumnInfo from, TableColumnInfo to) Returns the SQL that is used to change the column name. | public static List<String> | getColumnTypeAlterSQL(HibernateDialect dialect, String alterClause, String setClause, boolean repeatColumn, TableColumnInfo from, TableColumnInfo to) Returns the SQL that is used to change the column type. | public static List<String> | getCreateTableSQL(List<ITableInfo> tables, ISQLDatabaseMetaData md, HibernateDialect dialect, CreateScriptPreferences prefs, boolean isJdbcOdbc) | public static String | getDropForeignKeySQL(String fkName, String tableName) Returns the SQL command to drop the specified table's foreign key
constraint. | public static String | getDropPrimaryKeySQL(String pkName, String tableName, boolean useConstraintName, boolean cascadeConstraints) Returns the SQL command to drop the specified table's primary key. | public static void | getMultiColNotNullSQL(TableColumnInfo[] colInfos, HibernateDialect dialect, String alterClause, boolean specifyType, ArrayList<String> result) Populates the specified ArrayList with SQL statement(s) required to
convert each of the columns to not null. | public static TableColumnInfo | getRenamedColumn(TableColumnInfo info, String newColumnName) | public static List<String> | getTableDropSQL(ITableInfo iTableInfo, boolean supportsCascade, boolean cascadeValue, boolean supportsMatViews, String cascadeClause, boolean isMatView) Returns the SQL that forms the command to drop the specified table. | public static String | getTypeName(TableColumnInfo info, HibernateDialect dialect) | public static String | getUnsupportedMessage(HibernateDialect dialect, int featureId) |
ADD_DEFAULT_CLAUSE | final public static String ADD_DEFAULT_CLAUSE(Code) | | |
ADD_PRIMARY_KEY_TYPE | final public static int ADD_PRIMARY_KEY_TYPE(Code) | | |
ALTER_COLUMN_CLAUSE | final public static String ALTER_COLUMN_CLAUSE(Code) | | |
CASCADE_CLAUSE | final public static String CASCADE_CLAUSE(Code) | | |
CASCADE_CONSTRAINTS_CLAUSE | final public static String CASCADE_CONSTRAINTS_CLAUSE(Code) | | |
COLUMN_COMMENT_ALTER_TYPE | final public static int COLUMN_COMMENT_ALTER_TYPE(Code) | | |
COLUMN_DEFAULT_ALTER_TYPE | final public static int COLUMN_DEFAULT_ALTER_TYPE(Code) | | |
COLUMN_DROP_TYPE | final public static int COLUMN_DROP_TYPE(Code) | | |
COLUMN_NAME_ALTER_TYPE | final public static int COLUMN_NAME_ALTER_TYPE(Code) | | |
COLUMN_NULL_ALTER_TYPE | final public static int COLUMN_NULL_ALTER_TYPE(Code) | | |
COLUMN_TYPE_ALTER_TYPE | final public static int COLUMN_TYPE_ALTER_TYPE(Code) | | |
DEFAULT_CLAUSE | final public static String DEFAULT_CLAUSE(Code) | | |
DROP_COLUMN_CLAUSE | final public static String DROP_COLUMN_CLAUSE(Code) | | |
DROP_DEFAULT_CLAUSE | final public static String DROP_DEFAULT_CLAUSE(Code) | | |
DROP_PRIMARY_KEY_TYPE | final public static int DROP_PRIMARY_KEY_TYPE(Code) | | |
MODIFY_COLUMN_CLAUSE | final public static String MODIFY_COLUMN_CLAUSE(Code) | | |
RENAME_COLUMN_CLAUSE | final public static String RENAME_COLUMN_CLAUSE(Code) | | |
RENAME_TO_CLAUSE | final public static String RENAME_TO_CLAUSE(Code) | | |
SET_DATA_TYPE_CLAUSE | final public static String SET_DATA_TYPE_CLAUSE(Code) | | |
SET_DEFAULT_CLAUSE | final public static String SET_DEFAULT_CLAUSE(Code) | | |
getAddIndexSQL | public static String getAddIndexSQL(String indexName, boolean unique, TableColumnInfo[] columns)(Code) | | CREATE UNIQUE INDEX indexName ON tableName (columns);
Parameters: indexName - Parameters: tableName - Parameters: columns - |
getAddPrimaryKeySQL | public static String getAddPrimaryKeySQL(ITableInfo ti, String pkName, TableColumnInfo[] colInfos, boolean appendConstraintName)(Code) | | Returns the SQL for creating a primary key consisting of the specified
colInfos.
ALTER TABLE table_name ADD CONSTRAINT pkName PRIMARY KEY (col,...);
or
ALTER TABLE table_name ADD CONSTRAINT PRIMARY KEY (col,...) CONSTRAINT pkName;
Parameters: ti - TODO Parameters: colInfos - Parameters: appendConstraintName - whether or not the pkName (constraint name) should be placed at the end of the statement. |
getColumnAddSQL | public static String getColumnAddSQL(TableColumnInfo info, HibernateDialect dialect, boolean addDefaultClause, boolean supportsNullQualifier, boolean addNullClause) throws UnsupportedOperationException, HibernateException(Code) | | Returns the SQL statement to use to add a column to the specified table
using the information about the new column specified by info.
Parameters: info - information about the new column such as type, name, etc. Parameters: dialect - the HibernateDialect to use to resolve the type Parameters: addDefaultClause - whether or not the dialect's SQL supports a DEFAULT clause for columns. Parameters: addNullClause - TODO throws: UnsupportedOperationException - if the database doesn't support adding columns after a table has already been created. |
getColumnCommentAlterSQL | public static String getColumnCommentAlterSQL(String tableName, String columnName, String comment)(Code) | | Returns the SQL statement to use to add a comment to the specified
column of the specified table.
Parameters: tableName - the name of the table to create the SQL for. Parameters: columnName - the name of the column to create the SQL for. Parameters: comment - the comment to add. throws: UnsupportedOperationException - if the database doesn't support annotating columns with a comment. |
getColumnCommentAlterSQL | public static String getColumnCommentAlterSQL(TableColumnInfo info)(Code) | | Returns the SQL statement to use to add a comment to the specified
column of the specified table.
Parameters: tableName - the name of the table to create the SQL for. Parameters: columnName - the name of the column to create the SQL for. Parameters: comment - the comment to add. throws: UnsupportedOperationException - if the database doesn't support annotating columns with a comment. |
getColumnDefaultAlterSQL | public static String getColumnDefaultAlterSQL(HibernateDialect dialect, TableColumnInfo info, String alterClause, boolean specifyType, String defaultClause)(Code) | | Returns the SQL command to change the specified column's default value
ALTER TABLE table_name ALTER COLUMN column_name [defaultClause] 'defaultVal'
ALTER TABLE table_name ALTER COLUMN column_name [defaultClause] 1234
Parameters: dialect - TODO Parameters: info - the column to modify and it's default value. Parameters: specifyType - TODO SQL to make the change |
getColumnDropSQL | public static String getColumnDropSQL(String tableName, String columnName)(Code) | | Parameters: tableName - Parameters: columnName - |
getColumnDropSQL | public static String getColumnDropSQL(String tableName, String columnName, String dropClause, boolean addConstraintClause, String constraintClause)(Code) | | Parameters: tableName - Parameters: columnName - Parameters: addConstraintClause - TODO Parameters: constraintClause - TODO |
getColumnNameAlterSQL | public static String getColumnNameAlterSQL(TableColumnInfo from, TableColumnInfo to, String alterClause, String renameToClause)(Code) | | Returns the SQL that is used to change the column name.
ALTER TABLE table_name [alterClause] column_name [renameToClause] column_name
Parameters: from - the TableColumnInfo as it is Parameters: to - the TableColumnInfo as it wants to be the SQL to make the change |
getColumnNullableAlterSQL | public static String getColumnNullableAlterSQL(TableColumnInfo info, HibernateDialect dialect, String alterClause, boolean specifyType)(Code) | | Returns the SQL used to alter the specified column to allow/disallow null
values.
ALTER TABLE table_name <alterClause> column_name TYPE NULL | NOT NULL
ALTER TABLE table_name <alterClause> column_name NULL | NOT NULL
Parameters: info - the column to modify Parameters: dialect - the HibernateDialect representing the target database. Parameters: alterClause - the alter column clause (e.g. ALTER COLUMN ) Parameters: specifyType - whether or not the column type needs to be specified the SQL to execute |
getColumnNullableAlterSQL | public static String getColumnNullableAlterSQL(TableColumnInfo info, boolean nullable, HibernateDialect dialect, String alterClause, boolean specifyType)(Code) | | Returns the SQL used to alter the specified column to allow/disallow null
values.
ALTER TABLE table_name <alterClause> column_name TYPE NULL | NOT NULL
ALTER TABLE table_name <alterClause> column_name NULL | NOT NULL
Parameters: info - the column to modify Parameters: dialect - the HibernateDialect representing the target database. Parameters: alterClause - the alter column clause (e.g. ALTER COLUMN ) Parameters: specifyType - whether or not the column type needs to be specified the SQL to execute |
getColumnRenameSQL | public static String getColumnRenameSQL(TableColumnInfo from, TableColumnInfo to)(Code) | | Returns the SQL that is used to change the column name.
RENAME COLUMN table_name.column_name TO new_column_name
Parameters: from - the TableColumnInfo as it is Parameters: to - the TableColumnInfo as it wants to be the SQL to make the change |
getColumnTypeAlterSQL | public static List<String> getColumnTypeAlterSQL(HibernateDialect dialect, String alterClause, String setClause, boolean repeatColumn, TableColumnInfo from, TableColumnInfo to) throws UnsupportedOperationException(Code) | | Returns the SQL that is used to change the column type.
ALTER TABLE table_name alter_clause column_name [setClause] data_type
ALTER TABLE table_name alter_clause column_name column_name [setClause] data_type
Parameters: from - the TableColumnInfo as it is Parameters: to - the TableColumnInfo as it wants to be the SQL to make the change |
getDropForeignKeySQL | public static String getDropForeignKeySQL(String fkName, String tableName)(Code) | | Returns the SQL command to drop the specified table's foreign key
constraint.
Parameters: fkName - the name of the foreign key that should be dropped Parameters: tableName - the name of the table whose foreign key should be dropped |
getDropPrimaryKeySQL | public static String getDropPrimaryKeySQL(String pkName, String tableName, boolean useConstraintName, boolean cascadeConstraints)(Code) | | Returns the SQL command to drop the specified table's primary key.
alter table table_name drop primary key
or
alter table table_name drop constraint [pkName]
Parameters: pkName - the name of the primary key that should be dropped Parameters: tableName - the name of the table whose primary key should be dropped Parameters: useConstraintName - if true, the constraint name is used - like 'DROP CONSTRAINT pkName'; otherwisea generic 'DROP PRIMARY KEY' is used instead. Parameters: cascadeConstraints - whether or not to append 'CASCADE' to the end. |
getMultiColNotNullSQL | public static void getMultiColNotNullSQL(TableColumnInfo[] colInfos, HibernateDialect dialect, String alterClause, boolean specifyType, ArrayList<String> result)(Code) | | Populates the specified ArrayList with SQL statement(s) required to
convert each of the columns to not null. This is typically needed in
some databases when adding a primary key (some dbs do this step
automatically)
Parameters: colInfos - the columns to be made not null Parameters: dialect - Parameters: result - |
getTableDropSQL | public static List<String> getTableDropSQL(ITableInfo iTableInfo, boolean supportsCascade, boolean cascadeValue, boolean supportsMatViews, String cascadeClause, boolean isMatView)(Code) | | Returns the SQL that forms the command to drop the specified table. If
cascade contraints is supported by the dialect and cascadeConstraints is
true, then a drop statement with cascade constraints clause will be
formed.
Parameters: iTableInfo - the table to drop Parameters: supportsCascade - whether or not the cascade clause should be added. Parameters: cascadeValue - whether or not to drop any FKs that may reference the specified table. Parameters: supportsMatViews - TODO Parameters: cascadeClause - TODO Parameters: isMatView - TODO the drop SQL command. |
|
|