public abstract class AbstractBackend extends Object implements Backend
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY_STRING
the empty string.
|
protected static String |
TYPE_BIGINT |
protected static String |
TYPE_BIT |
protected static String |
TYPE_BLOB |
protected static String |
TYPE_BOOL |
protected static String |
TYPE_BOOLEAN |
protected static String |
TYPE_BYTE |
protected static String |
TYPE_BYTEA |
protected static String |
TYPE_CHAR_1 |
protected static String |
TYPE_DATE |
protected static String |
TYPE_DATETIME |
protected static String |
TYPE_DATETIME_YEAR_TO_SECOND |
protected static String |
TYPE_DECIMAL |
protected static String |
TYPE_DECIMAL_19 |
protected static String |
TYPE_DOUBLE |
protected static String |
TYPE_FLOAT |
protected static String |
TYPE_FLOAT4 |
protected static String |
TYPE_FLOAT8 |
protected static String |
TYPE_INT |
protected static String |
TYPE_INT2 |
protected static String |
TYPE_INT4 |
protected static String |
TYPE_INT8 |
protected static String |
TYPE_INTEGER |
protected static String |
TYPE_NCHAR_1 |
protected static String |
TYPE_NUMBER |
protected static String |
TYPE_NUMBER_1 |
protected static String |
TYPE_NUMBER_10 |
protected static String |
TYPE_NUMBER_19 |
protected static String |
TYPE_NUMBER_5 |
protected static String |
TYPE_NVARCHAR |
protected static String |
TYPE_NVARCHAR_MAX |
protected static String |
TYPE_REAL |
protected static String |
TYPE_SMALLFLOAT |
protected static String |
TYPE_SMALLINT |
protected static String |
TYPE_TEXT |
protected static String |
TYPE_TIME |
protected static String |
TYPE_TIMESTAMP |
protected static String |
TYPE_TINYINT |
protected static String |
TYPE_VARBINARY_MAX |
protected static String |
TYPE_VARCHAR |
SQL_ALLSTAR, SQL_ALTER_COLUMN, SQL_ALTER_TABLE, SQL_AND, SQL_ANDNOT, SQL_COMMA, SQL_COMMA_PAR, SQL_DELETE, SQL_EQUAL, SQL_EQUAL_PAR, SQL_EQUAL_PAR_COMMA, SQL_EQUAL_ZERO, SQL_EXISTS, SQL_FROM, SQL_GREATER, SQL_GREATER_PAR, SQL_GREATEROREQUAL, SQL_GREATEROREQUAL_PAR, SQL_GROUPBY, SQL_IF_EXISTS, SQL_INSERT_INTO, SQL_INSERT_VALUES, SQL_ISNOTNULL, SQL_ISNULL, SQL_LEFT_PARENTHESIS, SQL_LESS, SQL_LESS_PAR, SQL_LESSOREQUAL, SQL_LESSOREQUAL_PAR, SQL_LIKE, SQL_LIKE_PAR, SQL_MAX, SQL_MIN, SQL_NOT, SQL_NOTEQUAL, SQL_NOTEQUAL_PAR, SQL_NOTEQUAL_ZERO, SQL_NOTLIKE, SQL_NOTLIKE_PAR, SQL_OR, SQL_ORDERBY, SQL_ORNOT, SQL_PAR, SQL_PAR_COMMA, SQL_PLUS_ONE, SQL_RIGHT_PARENTHESIS, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SET, SQL_SORTASC, SQL_SORTDESC, SQL_UPDATE, SQL_WHERE, SQL_WHEREALL, SQL_WHEREAND, SQL_WHERENOTHING, SQL_WHEREOR| Constructor and Description |
|---|
AbstractBackend() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowsExpressionsReferringToTablesBeingUpdated()
Determines whether backend allows expressions referring to tables being updated.
|
void |
assertValidName(String nameType,
String name)
Asserts that given string is a valid name and usage.
|
String |
buildSelectSql(String sql,
boolean writeLock,
int limit,
int offset)
Creates a select statement string from an inner sql string.
|
String |
columnTypeNullDefaultToString(String columnName,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Converts an sqltype, size, scale, nullable and default value to a database type declaration.
|
String |
columnTypeToString(SqlType sqlType,
int size,
int scale)
Converts an sqltype, size and scale to a database type declaration.
|
ColumnMetaData |
createColumnMetaData(TableMetaData tableMetaData)
Creates a column meta data instance.
|
Connection |
createConnection(String url,
String username,
char[] password)
Creates a jdbc connection.
|
IndexColumnMetaData |
createIndexColumnMetaData(IndexMetaData indexMetaData)
Creates an index column meta data instance.
|
IndexMetaData |
createIndexMetaData(TableMetaData tableMetaData)
Creates an index meta data instance.
|
TableMetaData |
createTableMetaData(ModelMetaData modelMetaData,
String tableName)
Creates a meta data instance.
|
protected String |
extractWhereClause(String sql,
int whereOffset)
Extracts the where clause from a given sql.
|
String |
getCoalesceKeyword()
Gets the keyword for the COALESCE function.
|
String |
getDefaultSchema()
Gets the default schema name.
Some backends store the objects in a default schema, if no explicit schema is given. |
int |
getDefaultSize(SqlType sqlType)
Gets the default size if no size given in model.
|
String |
getEmptyString()
Gets the empty string.
|
int |
getMaxScale(SqlType sqlType,
int size)
Returns the maximum scale for a given SQL-type and size.
|
int |
getMaxSize(SqlType sqlType)
Returns the maximum size for a given SQL-type.
|
DatabaseMetaData[] |
getMetaData(BackendInfo backendInfo)
Gets the metadata from the backend.
|
MigrationStrategy[] |
getMigrationStrategy(ColumnMetaData column,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Determines the best migration strategy.
|
ModelMetaData |
getModelMetaData(DatabaseMetaData[] metaData,
String[] schemas,
String... tableNames)
Retrieves the metadata.
|
TableMetaData |
getTableMetaData(ModelMetaData modelMetaData,
String tableName)
Gets the table meta data for a given table name.
|
boolean |
isCommunicationLinkException(SQLException ex)
Determines whether exception is a communication error.
|
boolean |
isConstraintException(SQLException ex)
Determines whether exception is a constraint violation.
|
boolean |
isDefaultEqual(ColumnMetaData column,
SqlType sqlType,
Object defaultValue)
Checks whether the column's default corresponds to the model's default value.
|
boolean |
isDropIfExistsEnabled()
Returns whether backend should add IF EXISTS for generated DROPs.
|
protected boolean |
isDropIfExistsSupported()
Adds "IF EXISTS" to drop clauses, if supported by the backend.
Makes migration a little more robust in case the same SQL scripts are applied to different databases than those used to generate the migration scripts for. |
boolean |
isMatchingName(String name)
Checks whether the backend belongs to the given name.
|
boolean |
isReleaseSavepointSupported()
Returns whether the backend supports releasing savepoints explicitly.
|
boolean |
isTemporaryName(String name)
Checks whether this is a temporary name.
Returns whether an entity-, attribute- or index-name is temporary and should not be taken into account for migration or even used in the model. Depending on the backend, temporary names start with an underscore or some other lead string. |
SqlType[] |
jdbcTypeToSqlType(int jdbcType,
int size,
int scale)
Converts the JDBC data type integer to a tentackle backend SqlTypes.
|
boolean |
needAliasForSubselect()
Returns whether backend needs an alias for a subselect.
|
boolean |
needSetLongWorkaround()
Checks whether we need a workaround for the (Ingres) setLong-Bug.
|
boolean |
needTxForFetchsize()
Checks for the (postgres) bug that fetchsize is ignored if not within a new transaction.
|
protected String |
normalizeDefault(String str)
Normalize the default string to compare.
|
String |
optimizeSql(String sql)
Optimize SQL code.
Replace WHERE 1=1 AND/OR to WHERE. |
void |
setDropIfExistsEnabled(boolean dropIfExistsEnabled)
Some database support drop index/constraint/column IF EXISTS.
This may be useful if migration scripts are generated against non-production databases that contain test indexes etc... Notice, that those temporary DDL changes should better use the temporary prefix (see Backend.isTemporaryName(String) in
order to be ignored by the migrator. |
String |
sqlAddColumn(String tableName,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to add a column.
|
String |
sqlAlterColumnComment(String tableName,
String columnName,
String comment)
Generates SQL code to alter the comment for an attribute.
|
String |
sqlAlterColumnDefault(String tableName,
String columnName,
SqlType sqlType,
Object defaultValue)
Generates sql code to change the default value a column.
|
String |
sqlAlterColumnNullConstraint(String tableName,
String columnName,
boolean nullable)
Generates sql code to change the null-constraint of a column.
|
String |
sqlAlterColumnType(String tableName,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to change the datatype of a column.
|
String |
sqlAlterTableComment(String tableName,
String comment)
Generates SQL code to alter the comment for a table.
|
String |
sqlAsBeforeTableAlias()
Gets the string before the table alias.
In most databases the " AS " is optional and some don't accept it all. |
String |
sqlComment(String text)
Create comment sql code that is interpreted as a comment by the backend.
|
String |
sqlCreateColumn(String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue,
boolean primaryKey,
boolean withTrailingComma)
Generates the attribute definition of a CREATE TABLE statement.
|
String |
sqlCreateColumnComment(String tableName,
String columnName,
String comment)
Generates SQL code to create the comment for an attribute.
|
String |
sqlCreateIndex(String tableName,
String indexName,
boolean unique,
String filterCondition,
String... columnNames)
Generates the CREATE INDEX statement.
|
protected String |
sqlCreateTableAttributeWithoutComment(String columnName,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue,
boolean primaryKey,
boolean withTrailingComma)
Generates the attribute definition of a CREATE TABLE statement.
|
String |
sqlCreateTableClosing(String tableName,
String comment)
Generates the last line of a CREATE TABLE statement.
|
String |
sqlCreateTableComment(String tableName,
String comment)
Generates SQL code to create the comment for a table.
|
String |
sqlCreateTableIntro(String tableName,
String comment)
Generates the first line of a CREATE TABLE statement.
|
protected String |
sqlCreateTableIntroWithoutComment(String tableName)
Generates the first line of a CREATE TABLE statement.
|
String |
sqlDropColumn(String tableName,
String columnName)
Generates sql code to drop a column.
|
String |
sqlDropIndex(String schemaName,
String tableNameWithoutSchema,
String indexName)
Generates the DROP INDEX statement.
|
String |
sqlFunction(String functionName,
String expression)
Creates an sql function expression.
|
String |
sqlJoin(JoinType type,
String joinedTableName,
String joinedTableAlias,
String join)
Creates a join clause.
|
void |
sqlJoinSelects(JoinType type,
boolean addColumns,
StringBuilder select,
String joinSelect,
String joinSelectIdAlias,
String joinAlias,
String join)
Generate SQL code for joining a table to an existing select.
|
String |
sqlJoinSelects(JoinType type,
boolean addColumns,
String select,
String joinSelect,
String joinSelectIdAlias,
String joinAlias,
String join)
Generate SQL code for joining a table to an existing select.
|
String |
sqlRenameAndAlterColumnType(String tableName,
String oldColumnName,
String newColumnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to rename a column.
|
String |
sqlRenameColumn(String tableName,
String oldColumnName,
String newColumnName)
Generates sql code to rename a column.
|
boolean |
sqlRequiresExtraCommit()
According to the JDBC-specs
Connection.setAutoCommit(boolean)(true)
should commit, but some backends require an extra Connection.commit(). |
boolean |
sqlResultSetIsClosedSupported()
Determines whether the jdbc driver supports
ResultSet.isClosed(). |
String |
sqlTypeToString(SqlType sqlType,
int size)
Converts the java SQL-type to the database type name.
|
String |
sqlUpdateToNotNull(String tableName,
String columnName,
SqlType sqlType,
Object defaultValue)
Generates code to update a column to a non-null value.
|
String |
toQuotedString(String str)
Converts a string to a string enclosed in single quotes.
|
String |
toString() |
String |
valueToLiteral(SqlType sqlType,
Object value)
Conberts a type and value to a literal string.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbuildSelectSql, getBackendId, getDriverClassName, getName, getReservedWords, isMatchingUrl, setLeadingSelectParameters, setTrailingSelectParameters, sqlCreateForeignKey, sqlDropForeignKey, sqlNextFromSequene, supportsSequencesprotected static final String TYPE_BIGINT
protected static final String TYPE_BIT
protected static final String TYPE_BLOB
protected static final String TYPE_BOOL
protected static final String TYPE_BOOLEAN
protected static final String TYPE_BYTEA
protected static final String TYPE_BYTE
protected static final String TYPE_CHAR_1
protected static final String TYPE_DATE
protected static final String TYPE_DATETIME
protected static final String TYPE_DATETIME_YEAR_TO_SECOND
protected static final String TYPE_DECIMAL
protected static final String TYPE_DECIMAL_19
protected static final String TYPE_DOUBLE
protected static final String TYPE_FLOAT
protected static final String TYPE_FLOAT4
protected static final String TYPE_FLOAT8
protected static final String TYPE_INT
protected static final String TYPE_INT2
protected static final String TYPE_INT4
protected static final String TYPE_INT8
protected static final String TYPE_INTEGER
protected static final String TYPE_NCHAR_1
protected static final String TYPE_NUMBER
protected static final String TYPE_NUMBER_1
protected static final String TYPE_NUMBER_5
protected static final String TYPE_NUMBER_10
protected static final String TYPE_NUMBER_19
protected static final String TYPE_NVARCHAR
protected static final String TYPE_NVARCHAR_MAX
protected static final String TYPE_REAL
protected static final String TYPE_TEXT
protected static final String TYPE_TIME
protected static final String TYPE_TIMESTAMP
protected static final String TYPE_TINYINT
protected static final String TYPE_SMALLFLOAT
protected static final String TYPE_SMALLINT
protected static final String TYPE_VARBINARY_MAX
protected static final String TYPE_VARCHAR
public static final String EMPTY_STRING
public boolean isMatchingName(String name)
BackendisMatchingName in interface Backendname - the backend's namepublic Connection createConnection(String url, String username, char[] password) throws SQLException
BackendcreateConnection in interface Backendurl - the jdbc urlusername - the usernamepassword - the passwordSQLException - if connection could not be establishedpublic DatabaseMetaData[] getMetaData(BackendInfo backendInfo) throws SQLException
BackendImportant: the connection of the metadata is open!
getMetaData in interface BackendbackendInfo - the backend infoSQLException - if failedpublic boolean isTemporaryName(String name)
BackendisTemporaryName in interface Backendname - the namepublic String getEmptyString()
BackendSome dbms (most famous: Oracle) handle empty strings as null. In such cases the empty string (e.g. Oracle) may consist of a single blank or whatever.
getEmptyString in interface Backendpublic String sqlAsBeforeTableAlias()
BackendsqlAsBeforeTableAlias in interface Backendpublic boolean needAliasForSubselect()
BackendneedAliasForSubselect in interface Backendpublic boolean sqlRequiresExtraCommit()
BackendConnection.setAutoCommit(boolean)(true)
should commit, but some backends require an extra Connection.commit().sqlRequiresExtraCommit in interface Backendpublic boolean sqlResultSetIsClosedSupported()
BackendResultSet.isClosed().sqlResultSetIsClosedSupported in interface Backendpublic String sqlComment(String text)
BackendsqlComment in interface Backendtext - any text, single or multilinepublic String sqlJoin(JoinType type, String joinedTableName, String joinedTableAlias, String join)
Backendpublic String sqlFunction(String functionName, String expression)
BackendExample:
sqlFunction("max", CN_ID) --> "MAX(id)"
sqlFunction in interface BackendfunctionName - the function name, will be translated to uppercaseexpression - the expression, may be nullpublic String getCoalesceKeyword()
BackendgetCoalesceKeyword in interface Backendpublic boolean allowsExpressionsReferringToTablesBeingUpdated()
BackendallowsExpressionsReferringToTablesBeingUpdated in interface Backendpublic boolean needSetLongWorkaround()
BackendneedSetLongWorkaround in interface Backendpublic boolean needTxForFetchsize()
BackendneedTxForFetchsize in interface Backendpublic boolean isConstraintException(SQLException ex)
BackendisConstraintException in interface Backendex - the exceptionpublic boolean isCommunicationLinkException(SQLException ex)
BackendisCommunicationLinkException in interface Backendex - the exceptionpublic int getMaxSize(SqlType sqlType)
BackendgetMaxSize in interface BackendsqlType - the SQL-typepublic int getMaxScale(SqlType sqlType, int size)
BackendgetMaxScale in interface BackendsqlType - the SQL-typesize - the size, 0 if unlimitedpublic int getDefaultSize(SqlType sqlType)
BackendgetDefaultSize in interface BackendsqlType - the SQL-typepublic String getDefaultSchema()
BackendgetDefaultSchema in interface Backendpublic ModelMetaData getModelMetaData(DatabaseMetaData[] metaData, String[] schemas, String... tableNames)
BackendgetModelMetaData in interface BackendmetaData - the meta data for the whole databaseschemas - the optional schemas to filter tables, null if no filtertableNames - the tables of the modelpublic TableMetaData getTableMetaData(ModelMetaData modelMetaData, String tableName)
BackendgetTableMetaData in interface BackendmodelMetaData - the model the table belongs totableName - the model's table namepublic TableMetaData createTableMetaData(ModelMetaData modelMetaData, String tableName)
BackendcreateTableMetaData in interface BackendmodelMetaData - the whole meta datatableName - the model's table namepublic ColumnMetaData createColumnMetaData(TableMetaData tableMetaData)
BackendcreateColumnMetaData in interface BackendtableMetaData - the table meta data this column belongs topublic IndexMetaData createIndexMetaData(TableMetaData tableMetaData)
BackendcreateIndexMetaData in interface BackendtableMetaData - the table meta data this index belongs topublic IndexColumnMetaData createIndexColumnMetaData(IndexMetaData indexMetaData)
BackendcreateIndexColumnMetaData in interface BackendindexMetaData - the meta meta data this column belongs topublic String sqlCreateTableIntro(String tableName, String comment)
BackendsqlCreateTableIntro in interface BackendtableName - the tablename with optional schema separated by a dotcomment - optional comment, null if noneprotected String sqlCreateTableIntroWithoutComment(String tableName)
tableName - the tablename with optional schema separated by a dotpublic String sqlCreateTableClosing(String tableName, String comment)
BackendsqlCreateTableClosing in interface BackendtableName - the tablename with optional schema separated by a dotcomment - optional comment, null if nonepublic String sqlCreateTableComment(String tableName, String comment)
BackendsqlCreateTableComment in interface BackendtableName - the table namecomment - optional comment, null if noneBackend.sqlCreateTableIntro(java.lang.String, java.lang.String) or Backend.sqlCreateTableClosing(java.lang.String, java.lang.String)public String sqlAlterTableComment(String tableName, String comment)
BackendsqlAlterTableComment in interface BackendtableName - the table namecomment - optional comment, null to clearpublic String columnTypeToString(SqlType sqlType, int size, int scale)
BackendcolumnTypeToString in interface BackendsqlType - the SQL typesize - the sizescale - the scalepublic String columnTypeNullDefaultToString(String columnName, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendcolumnTypeNullDefaultToString in interface BackendcolumnName - the database column namesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String valueToLiteral(SqlType sqlType, Object value)
BackendvalueToLiteral in interface BackendsqlType - the sql typevalue - the valuepublic String sqlCreateColumn(String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue, boolean primaryKey, boolean withTrailingComma)
BackendsqlCreateColumn in interface BackendcolumnName - the database column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valueprimaryKey - true if this is a primary keywithTrailingComma - true if append a commapublic boolean isDefaultEqual(ColumnMetaData column, SqlType sqlType, Object defaultValue)
BackendisDefaultEqual in interface Backendcolumn - the column to inspectsqlType - the sql typedefaultValue - the model's default valueprotected String normalizeDefault(String str)
str - the default value as a string, may be nullpublic MigrationStrategy[] getMigrationStrategy(ColumnMetaData column, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendgetMigrationStrategy in interface Backendcolumn - old column meta datacolumnName - new column namecomment - new commentsqlType - new sql typesize - new sizescale - new scalenullable - new nullabledefaultValue - new defaultpublic String sqlRenameColumn(String tableName, String oldColumnName, String newColumnName)
BackendsqlRenameColumn in interface BackendtableName - the tablenameoldColumnName - the old column namenewColumnName - the new column namepublic String sqlRenameAndAlterColumnType(String tableName, String oldColumnName, String newColumnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlRenameAndAlterColumnType in interface BackendtableName - the tablenameoldColumnName - the old column namenewColumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlAddColumn(String tableName, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlAddColumn in interface BackendtableName - the tablenamecolumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlDropColumn(String tableName, String columnName)
BackendsqlDropColumn in interface BackendtableName - the tablenamecolumnName - the new column namepublic String sqlAlterColumnType(String tableName, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlAlterColumnType in interface BackendtableName - the tablenamecolumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlAlterColumnNullConstraint(String tableName, String columnName, boolean nullable)
BackendsqlAlterColumnNullConstraint in interface BackendtableName - the tablenamecolumnName - the new column namenullable - true if NULL, else NOT NULLBackend.sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)public String sqlUpdateToNotNull(String tableName, String columnName, SqlType sqlType, Object defaultValue)
BackendsqlUpdateToNotNull in interface BackendtableName - the tablenamecolumnName - the column namesqlType - the sql typedefaultValue - the optional default value if defined in the modelpublic String sqlAlterColumnDefault(String tableName, String columnName, SqlType sqlType, Object defaultValue)
BackendsqlAlterColumnDefault in interface BackendtableName - the tablenamecolumnName - the new column namesqlType - the JDBC sql typedefaultValue - the optional default valueBackend.sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)protected String sqlCreateTableAttributeWithoutComment(String columnName, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue, boolean primaryKey, boolean withTrailingComma)
columnName - the database column namesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valueprimaryKey - true if this is a primary keywithTrailingComma - true if append a commapublic String sqlCreateColumnComment(String tableName, String columnName, String comment)
BackendsqlCreateColumnComment in interface BackendtableName - the table namecolumnName - the column namecomment - optional comment, null if noneBackend.sqlCreateColumn(java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object, boolean, boolean)public String sqlAlterColumnComment(String tableName, String columnName, String comment)
BackendsqlAlterColumnComment in interface BackendtableName - the table namecolumnName - the column namecomment - optional comment, null to clearBackend.sqlRenameAndAlterColumnType(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object) insteadpublic String sqlTypeToString(SqlType sqlType, int size)
BackendsqlTypeToString in interface BackendsqlType - the java sql typesize - the column's sizepublic String sqlCreateIndex(String tableName, String indexName, boolean unique, String filterCondition, String... columnNames)
BackendsqlCreateIndex in interface BackendtableName - the table nameindexName - the name of the indexunique - true if index is uniquefilterCondition - the filter condition (null if none)columnNames - the column names (with a leading '-' if descending)public String sqlDropIndex(String schemaName, String tableNameWithoutSchema, String indexName)
BackendsqlDropIndex in interface BackendschemaName - the optional schema, null if nonetableNameWithoutSchema - the table name without the schemaindexName - the name of the indexpublic void sqlJoinSelects(JoinType type, boolean addColumns, StringBuilder select, String joinSelect, String joinSelectIdAlias, String joinAlias, String join)
BackendsqlJoinSelects in interface Backendtype - the join typeaddColumns - true if columns of joined table should be added to the result setselect - the original select statementjoinSelect - the select to join with the original sql or just a tablenamejoinSelectIdAlias - extra id alias to add to the joined select, null if nonejoinAlias - the alias of the joined selectjoin - the join clauseprotected String extractWhereClause(String sql, int whereOffset)
sql - the sql statementwhereOffset - the location of WHERE in sqlpublic void assertValidName(String nameType, String name)
BackendassertValidName in interface BackendnameType - the type/usage of the namename - the namepublic SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
BackendThere may be more than one sqltype returned!
jdbcTypeToSqlType in interface BackendjdbcType - the jdbc data typesize - the column sizescale - the column's scaleTypespublic String toQuotedString(String str)
BackendtoQuotedString in interface Backendstr - the stringpublic String optimizeSql(String sql)
BackendoptimizeSql in interface Backendsql - the original sql codepublic String buildSelectSql(String sql, boolean writeLock, int limit, int offset)
Backend
sqlBuilder is anything as FROM... WHERE... ORDER BY....
It is decorated with a leading SELECT plus optional clauses
like for the given parameters.
buildSelectSql in interface Backendsql - the sql without leading SELECT.writeLock - true select should write locklimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clausepublic String sqlJoinSelects(JoinType type, boolean addColumns, String select, String joinSelect, String joinSelectIdAlias, String joinAlias, String join)
BackendsqlJoinSelects in interface Backendtype - the join typeaddColumns - true if columns of joined table should be added to the result setselect - the original select statementjoinSelect - the select to join with the original sql or just a tablenamejoinSelectIdAlias - extra id alias to add to the joined select, null if nonejoinAlias - the alias of the joined selectjoin - the join clausepublic boolean isReleaseSavepointSupported()
BackendisReleaseSavepointSupported in interface Backendpublic void setDropIfExistsEnabled(boolean dropIfExistsEnabled)
BackendBackend.isTemporaryName(String) in
order to be ignored by the migrator.setDropIfExistsEnabled in interface BackenddropIfExistsEnabled - true if use IF EXISTS if the backend supports itpublic boolean isDropIfExistsEnabled()
BackendisDropIfExistsEnabled in interface Backendprotected boolean isDropIfExistsSupported()
Tentackle - distributed, domain- and model-driven