-
- All Known Implementing Classes:
AbstractBackend,AbstractSql2003Backend,AbstractSql2008Backend,AbstractSql92Backend,Db2,Informix,Ingres,MariaDb,MsSql,MySql,Oracle,Postgres
public interface BackendA database backend.
Defines the backend specifics.
There is only one instance per database type.
Implementations must not maintain any state except for the whole of all connections to the specific kind of database.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSQL_ALLSTAR'*' all string.static java.lang.StringSQL_ALTER_COLUMNSQL ALTER COLUMN fragment.static java.lang.StringSQL_ALTER_INDEXSQL ALTER INDEX intro.static java.lang.StringSQL_ALTER_TABLESQL ALTER TABLE intro.static java.lang.StringSQL_ANDAND string.static java.lang.StringSQL_ANDNOTAND NOT string.static java.lang.StringSQL_ARRAY_ALLALL array operator string.static java.lang.StringSQL_ARRAY_ALL_PARParameter ALL array operator string.static java.lang.StringSQL_ARRAY_ANYANY array operator string.static java.lang.StringSQL_ARRAY_ANY_PARParameter ANY array operator string.static java.lang.StringSQL_ARRAY_ININ array operator string.static java.lang.StringSQL_ARRAY_IN_PARParameter IN array operator string.static java.lang.StringSQL_ARRAY_NOT_INNOT IN array operator string.static java.lang.StringSQL_ARRAY_NOT_IN_PARParameter NOT IN array operator string.static java.lang.StringSQL_ARRAY_PARArray parameter (?).static java.lang.StringSQL_COMMAcomma separator.static java.lang.StringSQL_COMMA_PARParameter ,? string.static java.lang.StringSQL_DELETEDELETE string.static java.lang.StringSQL_EQUAL= operator string.static java.lang.StringSQL_EQUAL_PARParameter =? string.static java.lang.StringSQL_EQUAL_PAR_COMMAParameter =?, string.static java.lang.StringSQL_EQUAL_ZERO=0 string.static java.lang.StringSQL_EXISTSSQL EXISTS clause with SELECT 1 and opening left parenthesis.static java.lang.StringSQL_FROMFROM string.static java.lang.StringSQL_GREATER> operator string.static java.lang.StringSQL_GREATER_PARParameter >? string.static java.lang.StringSQL_GREATEROREQUAL>= operator string.static java.lang.StringSQL_GREATEROREQUAL_PARParameter ≥? string.static java.lang.StringSQL_GROUPBYGROUP BY string.static java.lang.StringSQL_IF_EXISTSSQL IF EXISTS fragment.static java.lang.StringSQL_INSERT_INTOINSERT INTO string.static java.lang.StringSQL_INSERT_VALUES(VALUES) string for insert.static java.lang.StringSQL_ISNOTNULLIS NOT NULL string.static java.lang.StringSQL_ISNULLIS NULL string.static java.lang.StringSQL_LEFT_PARENTHESISopening bracket.static java.lang.StringSQL_LESS< operator string.static java.lang.StringSQL_LESS_PARParameter <? string.static java.lang.StringSQL_LESSOREQUAL<= operator string.static java.lang.StringSQL_LESSOREQUAL_PARParameter <=? string.static java.lang.StringSQL_LIKELIKE operator string.static java.lang.StringSQL_LIKE_PARParameter LIKE ? string.static java.lang.StringSQL_MAXMAX function name.static java.lang.StringSQL_MINMAX function name.static java.lang.StringSQL_NOTNOT string.static java.lang.StringSQL_NOTEQUAL<> operator string.static java.lang.StringSQL_NOTEQUAL_PARParameter <>? string.static java.lang.StringSQL_NOTEQUAL_ZERO<>0 string.static java.lang.StringSQL_NOTLIKENOT LIKE operator string.static java.lang.StringSQL_NOTLIKE_PARParameter NOT LIKE ? string.static java.lang.StringSQL_OROR string.static java.lang.StringSQL_ORDERBYORDER BY string.static java.lang.StringSQL_ORNOTOR NOT string.static java.lang.StringSQL_PAR? string.static java.lang.StringSQL_PAR_COMMAParameter ?, string.static java.lang.StringSQL_PLUS_ONE+1 string.static java.lang.StringSQL_RIGHT_PARENTHESISclosing bracket.static java.lang.StringSQL_SELECTSELECT string.static java.lang.StringSQL_SELECT_ALL_FROMSELECT * FROM string.static java.lang.StringSQL_SETSET string.static java.lang.StringSQL_SORTASCsort ASC string.static java.lang.StringSQL_SORTDESCsort DESC string.static java.lang.StringSQL_UPDATEUPDATE string.static java.lang.StringSQL_WHEREWHERE string.static java.lang.StringSQL_WHEREALL"WHERE 1=1" allows AND to be added.static java.lang.StringSQL_WHEREANDSQL_WHEREALL + AND will be replaced by...static java.lang.StringSQL_WHERENOTHING"WHERE 1=0" to select nothing.static java.lang.StringSQL_WHEREORSQL_WHEREALL + OR will be replaced by...
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanallowsExpressionsReferringToTablesBeingUpdated()Determines whether backend allows expressions referring to tables being updated.voidassertValidName(SqlNameType nameType, java.lang.String name)Asserts that given string is a valid name and usage.voidbuildSelectSql(java.lang.StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)Creates a select statement string from an inner sql string.java.lang.StringbuildSelectSql(java.lang.String sql, boolean writeLock, int limit, int offset)Creates a select statement string from an inner sql string.java.lang.StringcolumnTypeNullDefaultToString(java.lang.String columnName, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Converts an sqltype, size, scale, nullable and default value to a database type declaration.java.lang.StringcolumnTypeToString(SqlType sqlType, int size, int scale)Converts an sqltype, size and scale to a database type declaration.ColumnMetaDatacreateColumnMetaData(TableMetaData tableMetaData)Creates a column meta data instance.java.sql.ConnectioncreateConnection(java.lang.String url, java.lang.String username, char[] password)Creates a jdbc connection.IndexColumnMetaDatacreateIndexColumnMetaData(IndexMetaData indexMetaData)Creates an index column meta data instance.IndexMetaDatacreateIndexMetaData(TableMetaData tableMetaData)Creates an index meta data instance.TableMetaDatacreateTableMetaData(ModelMetaData metaData, java.lang.String tableName)Creates a meta data instance.java.lang.StringgetBackendId(java.sql.Connection connection)Determines the unique id or name used by the backend for a given connection.java.lang.StringgetCoalesceKeyword()Gets the keyword for the COALESCE function.java.lang.StringgetDefaultSchema()Gets the default schema name.
Some backends store the objects in a default schema, if no explicit schema is given.intgetDefaultSize(SqlType sqlType)Gets the default size if no size given in model.java.lang.StringgetDriverClassName()Gets the JDBC driver class name.java.lang.StringgetEmptyString()Gets the empty string.intgetMaxScale(SqlType sqlType, int size)Returns the maximum scale for a given SQL-type and size.intgetMaxSize(SqlType sqlType)Returns the maximum size for a given SQL-type.java.sql.DatabaseMetaData[]getMetaData(BackendInfo backendInfo)Gets the metadata from the backend.MigrationStrategy[]getMigrationStrategy(ColumnMetaData column, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Determines the best migration strategy.ModelMetaDatagetModelMetaData(java.sql.DatabaseMetaData[] metaData, java.lang.String[] schemas, java.lang.String... tableNames)Retrieves the metadata.java.lang.StringgetName()Gets the name of the backend.java.util.Set<java.lang.String>getReservedWords()Gets the list of reserved words for this backend.java.util.List<DatabaseMetaDataTableHeader>getTableHeaders(java.sql.DatabaseMetaData metaData)Gets all table headers for a given metadata.TableMetaDatagetTableMetaData(ModelMetaData modelMetaData, java.lang.String tableName)Gets the table meta data for a given table name.booleanisArrayOperatorSupported(java.lang.String operator)Returns whether the backend supports given array operator.booleanisClobSupported()Returns whether the backend support CLOB types.
If not, it will be emulated as VARCHAR with the maximum possible size.booleanisCommunicationLinkException(java.sql.SQLException ex)Determines whether exception is a communication error.booleanisConstraintException(java.sql.SQLException ex)Determines whether exception is a constraint violation.booleanisDefaultEqual(ColumnMetaData column, SqlType sqlType, java.lang.Object defaultValue)Checks whether the column's default corresponds to the model's default value.booleanisDropIfExistsEnabled()Returns whether backend should add IF EXISTS for generated DROPs.booleanisFilteredIndexSupported()Returns whether backend supports filtered indexes.booleanisFunctionBasedIndexSupported()Returns whether function based indexes are supported.booleanisMatchingName(java.lang.String name)Checks whether the backend belongs to the given name.booleanisMatchingUrl(java.lang.String url)Checks whether the backend belongs to the given jdbc url.
If multiple backend implementations are provided for the same database type, only one backend should match the URL.booleanisReleaseSavepointSupported()Returns whether the backend supports releasing savepoints explicitly.booleanisReservedSchemaName(java.lang.String name)Checks whether this is a reserved schema name for this backend.booleanisReservedTableName(java.lang.String name)Checks whether this a reserved table name for this backend.
Applies only to tables.booleanisTemporaryName(java.lang.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.booleanneedAliasForSubselect()Returns whether backend needs an alias for a subselect.booleanneedSetLongWorkaround()Checks whether we need a workaround for the (Ingres) setLong-Bug.booleanneedTxForFetchsize()Checks for the (postgres) bug that fetchsize is ignored if not within a new transaction.java.lang.StringoptimizeSql(java.lang.String sql)Optimize SQL code.
Replace WHERE 1=1 AND/OR to WHERE.voidsetArray(java.sql.PreparedStatement statement, int pos, SqlType type, java.util.Collection<?> elements, java.lang.String operator)Sets an array parameter in a prepared statement.voidsetDropIfExistsEnabled(boolean dropIfExists)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 (seeisTemporaryName(String)in order to be ignored by the migrator.intsetLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)Sets optional parameters before applying the original parameters.intsetTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)Sets optional parameters after applying the original parameters.java.lang.StringsqlAddColumn(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to add a column.java.lang.StringsqlAlterColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Generates SQL code to alter the comment for an attribute.java.lang.StringsqlAlterColumnDefault(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Generates sql code to change the default value a column.java.lang.StringsqlAlterColumnNullConstraint(java.lang.String tableName, java.lang.String columnName, boolean nullable)Generates sql code to change the null-constraint of a column.java.lang.StringsqlAlterColumnType(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to change the datatype of a column.java.lang.StringsqlAlterTableComment(java.lang.String tableName, java.lang.String comment)Generates SQL code to alter the comment for a table.java.lang.StringsqlAsBeforeTableAlias()Gets the string before the table alias.
In most databases the " AS " is optional and some don't accept it all.java.lang.StringsqlComment(java.lang.String text)Create comment sql code that is interpreted as a comment by the backend.java.lang.StringsqlCreateColumn(java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue, boolean primaryKey, boolean withTrailingComma)Generates the attribute definition of a CREATE TABLE statement.java.lang.StringsqlCreateColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Generates SQL code to create the comment for an attribute.java.lang.StringsqlCreateForeignKey(java.lang.String referencingTableName, java.lang.String referencingColumnName, java.lang.String referencedTableName, java.lang.String referencedColumnName, java.lang.String foreignKeyName, boolean composite)Generates the ALTER TABLE statement to add a foreign key constraint.java.lang.StringsqlCreateIndex(java.lang.String tableName, java.lang.String indexName, boolean unique, java.lang.String filterCondition, java.lang.String... columnNames)Generates the CREATE INDEX statement.java.lang.StringsqlCreateTableClosing(java.lang.String tableName, java.lang.String comment)Generates the last line of a CREATE TABLE statement.java.lang.StringsqlCreateTableComment(java.lang.String tableName, java.lang.String comment)Generates SQL code to create the comment for a table.java.lang.StringsqlCreateTableIntro(java.lang.String tableName, java.lang.String comment)Generates the first line of a CREATE TABLE statement.java.lang.StringsqlDropColumn(java.lang.String tableName, java.lang.String columnName)Generates sql code to drop a column.java.lang.StringsqlDropForeignKey(java.lang.String referencingTableName, java.lang.String foreignKeyName)Generates the sql statement to drop a foreign key constraint.java.lang.StringsqlDropIndex(java.lang.String schemaName, java.lang.String tableNameWithoutSchema, java.lang.String indexName)Generates the DROP INDEX statement.java.lang.StringsqlDropTable(java.lang.String schemaName, java.lang.String tableNameWithoutSchema)Generates the DROP TABLE statement.java.lang.StringsqlFunction(java.lang.String functionName, java.lang.String expression)Creates an sql function expression.java.lang.StringsqlJoin(JoinType type, java.lang.String joinedTableName, java.lang.String joinedTableAlias, java.lang.String join)Creates a join clause.voidsqlJoinSelects(JoinType type, boolean addColumns, java.lang.StringBuilder select, java.lang.String joinSelect, java.lang.String joinSelectIdAlias, java.lang.String joinAlias, java.lang.String join)Generate SQL code for joining a table to an existing select.java.lang.StringsqlJoinSelects(JoinType type, boolean addColumns, java.lang.String select, java.lang.String joinSelect, java.lang.String joinSelectIdAlias, java.lang.String joinAlias, java.lang.String join)Generate SQL code for joining a table to an existing select.java.lang.StringsqlNextFromSequene(java.lang.String name)Creates the SQL string to retrieve the next id from a sequence.java.lang.StringsqlRenameAndAlterColumnType(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to rename a column.java.lang.StringsqlRenameColumn(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName)Generates sql code to rename a column.java.lang.StringsqlRenameIndex(java.lang.String tableName, java.lang.String oldIndexName, java.lang.String newIndexName)Generates sql code to rename an index.java.lang.StringsqlRenameTable(java.lang.String tableName, java.lang.String newTableName)Generate sql code to rename a table.booleansqlRequiresExtraCommit()According to the JDBC-specsConnection.setAutoCommit(boolean)(true) should commit, but some backends require an extraConnection.commit().booleansqlResultSetIsClosedSupported()Determines whether the jdbc driver supportsResultSet.isClosed().java.lang.StringsqlTypeToString(SqlType sqlType, int size)Converts the java SQL-type to the database type name.java.lang.StringsqlUpdateToNotNull(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Generates code to update a column to a non-null value.booleansupportsSequences()True if backend provides transactionless sequences.java.lang.StringtoInternalType(java.lang.String sqlTypeName)Converts a backend specific type name to an internal name used by driver specific methods.java.lang.StringtoQuotedString(java.lang.String str)Converts a string to a string enclosed in single quotes.java.lang.StringvalueToLiteral(SqlType sqlType, java.lang.Object value)Conberts a type and value to a literal string.
-
-
-
Field Detail
-
SQL_WHERE
static final java.lang.String SQL_WHERE
WHERE string.- See Also:
- Constant Field Values
-
SQL_SELECT
static final java.lang.String SQL_SELECT
SELECT string.- See Also:
- Constant Field Values
-
SQL_SELECT_ALL_FROM
static final java.lang.String SQL_SELECT_ALL_FROM
SELECT * FROM string.- See Also:
- Constant Field Values
-
SQL_DELETE
static final java.lang.String SQL_DELETE
DELETE string.- See Also:
- Constant Field Values
-
SQL_UPDATE
static final java.lang.String SQL_UPDATE
UPDATE string.- See Also:
- Constant Field Values
-
SQL_INSERT_INTO
static final java.lang.String SQL_INSERT_INTO
INSERT INTO string.- See Also:
- Constant Field Values
-
SQL_LEFT_PARENTHESIS
static final java.lang.String SQL_LEFT_PARENTHESIS
opening bracket.- See Also:
- Constant Field Values
-
SQL_RIGHT_PARENTHESIS
static final java.lang.String SQL_RIGHT_PARENTHESIS
closing bracket.- See Also:
- Constant Field Values
-
SQL_INSERT_VALUES
static final java.lang.String SQL_INSERT_VALUES
(VALUES) string for insert.- See Also:
- Constant Field Values
-
SQL_SET
static final java.lang.String SQL_SET
SET string.- See Also:
- Constant Field Values
-
SQL_FROM
static final java.lang.String SQL_FROM
FROM string.- See Also:
- Constant Field Values
-
SQL_AND
static final java.lang.String SQL_AND
AND string.- See Also:
- Constant Field Values
-
SQL_OR
static final java.lang.String SQL_OR
OR string.- See Also:
- Constant Field Values
-
SQL_NOT
static final java.lang.String SQL_NOT
NOT string.- See Also:
- Constant Field Values
-
SQL_ANDNOT
static final java.lang.String SQL_ANDNOT
AND NOT string.- See Also:
- Constant Field Values
-
SQL_ORNOT
static final java.lang.String SQL_ORNOT
OR NOT string.- See Also:
- Constant Field Values
-
SQL_COMMA
static final java.lang.String SQL_COMMA
comma separator.- See Also:
- Constant Field Values
-
SQL_PAR
static final java.lang.String SQL_PAR
? string.- See Also:
- Constant Field Values
-
SQL_ARRAY_PAR
static final java.lang.String SQL_ARRAY_PAR
Array parameter (?).- See Also:
- Constant Field Values
-
SQL_EQUAL
static final java.lang.String SQL_EQUAL
= operator string.- See Also:
- Constant Field Values
-
SQL_NOTEQUAL
static final java.lang.String SQL_NOTEQUAL
<> operator string.- See Also:
- Constant Field Values
-
SQL_LESS
static final java.lang.String SQL_LESS
< operator string.- See Also:
- Constant Field Values
-
SQL_GREATER
static final java.lang.String SQL_GREATER
> operator string.- See Also:
- Constant Field Values
-
SQL_LESSOREQUAL
static final java.lang.String SQL_LESSOREQUAL
<= operator string.- See Also:
- Constant Field Values
-
SQL_GREATEROREQUAL
static final java.lang.String SQL_GREATEROREQUAL
>= operator string.- See Also:
- Constant Field Values
-
SQL_LIKE
static final java.lang.String SQL_LIKE
LIKE operator string.- See Also:
- Constant Field Values
-
SQL_NOTLIKE
static final java.lang.String SQL_NOTLIKE
NOT LIKE operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_IN
static final java.lang.String SQL_ARRAY_IN
IN array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_NOT_IN
static final java.lang.String SQL_ARRAY_NOT_IN
NOT IN array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_ANY
static final java.lang.String SQL_ARRAY_ANY
ANY array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_ALL
static final java.lang.String SQL_ARRAY_ALL
ALL array operator string.- See Also:
- Constant Field Values
-
SQL_EQUAL_ZERO
static final java.lang.String SQL_EQUAL_ZERO
=0 string.- See Also:
- Constant Field Values
-
SQL_NOTEQUAL_ZERO
static final java.lang.String SQL_NOTEQUAL_ZERO
<>0 string.- See Also:
- Constant Field Values
-
SQL_COMMA_PAR
static final java.lang.String SQL_COMMA_PAR
Parameter ,? string.- See Also:
- Constant Field Values
-
SQL_PAR_COMMA
static final java.lang.String SQL_PAR_COMMA
Parameter ?, string.- See Also:
- Constant Field Values
-
SQL_EQUAL_PAR
static final java.lang.String SQL_EQUAL_PAR
Parameter =? string.- See Also:
- Constant Field Values
-
SQL_EQUAL_PAR_COMMA
static final java.lang.String SQL_EQUAL_PAR_COMMA
Parameter =?, string.- See Also:
- Constant Field Values
-
SQL_NOTEQUAL_PAR
static final java.lang.String SQL_NOTEQUAL_PAR
Parameter <>? string.- See Also:
- Constant Field Values
-
SQL_GREATER_PAR
static final java.lang.String SQL_GREATER_PAR
Parameter >? string.- See Also:
- Constant Field Values
-
SQL_GREATEROREQUAL_PAR
static final java.lang.String SQL_GREATEROREQUAL_PAR
Parameter ≥? string.- See Also:
- Constant Field Values
-
SQL_LESS_PAR
static final java.lang.String SQL_LESS_PAR
Parameter <? string.- See Also:
- Constant Field Values
-
SQL_LESSOREQUAL_PAR
static final java.lang.String SQL_LESSOREQUAL_PAR
Parameter <=? string.- See Also:
- Constant Field Values
-
SQL_LIKE_PAR
static final java.lang.String SQL_LIKE_PAR
Parameter LIKE ? string.- See Also:
- Constant Field Values
-
SQL_NOTLIKE_PAR
static final java.lang.String SQL_NOTLIKE_PAR
Parameter NOT LIKE ? string.- See Also:
- Constant Field Values
-
SQL_ARRAY_IN_PAR
static final java.lang.String SQL_ARRAY_IN_PAR
Parameter IN array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_NOT_IN_PAR
static final java.lang.String SQL_ARRAY_NOT_IN_PAR
Parameter NOT IN array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_ANY_PAR
static final java.lang.String SQL_ARRAY_ANY_PAR
Parameter ANY array operator string.- See Also:
- Constant Field Values
-
SQL_ARRAY_ALL_PAR
static final java.lang.String SQL_ARRAY_ALL_PAR
Parameter ALL array operator string.- See Also:
- Constant Field Values
-
SQL_ALLSTAR
static final java.lang.String SQL_ALLSTAR
'*' all string.- See Also:
- Constant Field Values
-
SQL_PLUS_ONE
static final java.lang.String SQL_PLUS_ONE
+1 string.- See Also:
- Constant Field Values
-
SQL_WHEREALL
static final java.lang.String SQL_WHEREALL
"WHERE 1=1" allows AND to be added.- See Also:
- Constant Field Values
-
SQL_WHERENOTHING
static final java.lang.String SQL_WHERENOTHING
"WHERE 1=0" to select nothing.- See Also:
- Constant Field Values
-
SQL_WHEREAND
static final java.lang.String SQL_WHEREAND
SQL_WHEREALL + AND will be replaced by... SQL_WHERE.- See Also:
- Constant Field Values
-
SQL_WHEREOR
static final java.lang.String SQL_WHEREOR
SQL_WHEREALL + OR will be replaced by... SQL_WHERE.- See Also:
- Constant Field Values
-
SQL_ISNULL
static final java.lang.String SQL_ISNULL
IS NULL string.- See Also:
- Constant Field Values
-
SQL_ISNOTNULL
static final java.lang.String SQL_ISNOTNULL
IS NOT NULL string.- See Also:
- Constant Field Values
-
SQL_ORDERBY
static final java.lang.String SQL_ORDERBY
ORDER BY string.- See Also:
- Constant Field Values
-
SQL_SORTASC
static final java.lang.String SQL_SORTASC
sort ASC string.- See Also:
- Constant Field Values
-
SQL_SORTDESC
static final java.lang.String SQL_SORTDESC
sort DESC string.- See Also:
- Constant Field Values
-
SQL_GROUPBY
static final java.lang.String SQL_GROUPBY
GROUP BY string.- See Also:
- Constant Field Values
-
SQL_MAX
static final java.lang.String SQL_MAX
MAX function name.- See Also:
- Constant Field Values
-
SQL_MIN
static final java.lang.String SQL_MIN
MAX function name.- See Also:
- Constant Field Values
-
SQL_EXISTS
static final java.lang.String SQL_EXISTS
SQL EXISTS clause with SELECT 1 and opening left parenthesis.- See Also:
- Constant Field Values
-
SQL_ALTER_TABLE
static final java.lang.String SQL_ALTER_TABLE
SQL ALTER TABLE intro.- See Also:
- Constant Field Values
-
SQL_ALTER_INDEX
static final java.lang.String SQL_ALTER_INDEX
SQL ALTER INDEX intro.- See Also:
- Constant Field Values
-
SQL_ALTER_COLUMN
static final java.lang.String SQL_ALTER_COLUMN
SQL ALTER COLUMN fragment.- See Also:
- Constant Field Values
-
SQL_IF_EXISTS
static final java.lang.String SQL_IF_EXISTS
SQL IF EXISTS fragment.- See Also:
- Constant Field Values
-
-
Method Detail
-
isMatchingUrl
boolean isMatchingUrl(java.lang.String url)
Checks whether the backend belongs to the given jdbc url.
If multiple backend implementations are provided for the same database type, only one backend should match the URL. The others must be selected via name.- Parameters:
url- the jdbc url- Returns:
- true if matches
-
isMatchingName
boolean isMatchingName(java.lang.String name)
Checks whether the backend belongs to the given name.- Parameters:
name- the backend's name- Returns:
- true if matches
-
getName
java.lang.String getName()
Gets the name of the backend.- Returns:
- the name
-
getDriverClassName
java.lang.String getDriverClassName()
Gets the JDBC driver class name.- Returns:
- the class name
-
createConnection
java.sql.Connection createConnection(java.lang.String url, java.lang.String username, char[] password) throws java.sql.SQLExceptionCreates a jdbc connection.- Parameters:
url- the jdbc urlusername- the usernamepassword- the password- Returns:
- the created connection
- Throws:
java.sql.SQLException- if connection could not be established
-
getMetaData
java.sql.DatabaseMetaData[] getMetaData(BackendInfo backendInfo) throws java.sql.SQLException
Gets the metadata from the backend.Important: the connection of the metadata is open!
- Parameters:
backendInfo- the backend info- Returns:
- the metadata, may be more than one if schemas set in backendInfo
- Throws:
java.sql.SQLException- if failed
-
getTableHeaders
java.util.List<DatabaseMetaDataTableHeader> getTableHeaders(java.sql.DatabaseMetaData metaData) throws java.sql.SQLException
Gets all table headers for a given metadata.- Parameters:
metaData- the database metadata- Returns:
- the list of table headers
- Throws:
java.sql.SQLException- if failed
-
isTemporaryName
boolean isTemporaryName(java.lang.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.- Parameters:
name- the name- Returns:
- true temporary (invalid) name
-
isReservedTableName
boolean isReservedTableName(java.lang.String name)
Checks whether this a reserved table name for this backend.
Applies only to tables. Not to be mixed up withgetReservedWords().
Useful to avoid conflicts with naming conventions for backend specific things, such as snapshots.- Parameters:
name- the table name- Returns:
- true if reserved by backend
-
isReservedSchemaName
boolean isReservedSchemaName(java.lang.String name)
Checks whether this is a reserved schema name for this backend.- Parameters:
name- the schema name- Returns:
- true if reserved by backend
-
buildSelectSql
void buildSelectSql(java.lang.StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)Creates a select statement string from an inner sql string.sqlBuilderis anything asFROM... WHERE... ORDER BY....
It is decorated with a leadingSELECTplus optional clauses like for the given parameters.- Parameters:
sqlBuilder- the sql builder, initially containing the inner sql without leadingSELECT.writeLock- true select should write locklimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause
-
buildSelectSql
java.lang.String buildSelectSql(java.lang.String sql, boolean writeLock, int limit, int offset)Creates a select statement string from an inner sql string.sqlBuilderis anything asFROM... WHERE... ORDER BY....
It is decorated with a leadingSELECTplus optional clauses like for the given parameters.- Parameters:
sql- the sql without leadingSELECT.writeLock- true select should write locklimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the select statement
-
setLeadingSelectParameters
int setLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)
Sets optional parameters before applying the original parameters.- Parameters:
stmt- the prepared statementlimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the next parameter index
-
setTrailingSelectParameters
int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)
Sets optional parameters after applying the original parameters.- Parameters:
stmt- the prepared statementindex- the first parameter indexlimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the next parameter index
-
getEmptyString
java.lang.String getEmptyString()
Gets the empty string.Some 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.
- Returns:
- the empty string (never null)
-
sqlRequiresExtraCommit
boolean sqlRequiresExtraCommit()
According to the JDBC-specsConnection.setAutoCommit(boolean)(true) should commit, but some backends require an extraConnection.commit().- Returns:
- true if the database needs an extra commit
-
sqlResultSetIsClosedSupported
boolean sqlResultSetIsClosedSupported()
Determines whether the jdbc driver supportsResultSet.isClosed().- Returns:
- true if the driver supports it
-
getCoalesceKeyword
java.lang.String getCoalesceKeyword()
Gets the keyword for the COALESCE function.- Returns:
- the keyword
-
allowsExpressionsReferringToTablesBeingUpdated
boolean allowsExpressionsReferringToTablesBeingUpdated()
Determines whether backend allows expressions referring to tables being updated.- Returns:
- true if allowed
-
supportsSequences
boolean supportsSequences()
True if backend provides transactionless sequences.- Returns:
- true if database supports sequences
-
sqlAsBeforeTableAlias
java.lang.String sqlAsBeforeTableAlias()
Gets the string before the table alias.
In most databases the " AS " is optional and some don't accept it all.- Returns:
- the as-string
-
needAliasForSubselect
boolean needAliasForSubselect()
Returns whether backend needs an alias for a subselect.- Returns:
- true if subselect needs an alias.
-
sqlNextFromSequene
java.lang.String sqlNextFromSequene(java.lang.String name)
Creates the SQL string to retrieve the next id from a sequence.- Parameters:
name- the name of the sequence- Returns:
- the SQL code
-
sqlComment
java.lang.String sqlComment(java.lang.String text)
Create comment sql code that is interpreted as a comment by the backend.- Parameters:
text- any text, single or multiline- Returns:
- the comment, null if text was null
-
sqlJoin
java.lang.String sqlJoin(JoinType type, java.lang.String joinedTableName, java.lang.String joinedTableAlias, java.lang.String join)
Creates a join clause.- Parameters:
type- the join typejoinedTableName- the joined tablenamejoinedTableAlias- the joined table alias, null if nonejoin- the join expression- Returns:
- the sql code
-
sqlFunction
java.lang.String sqlFunction(java.lang.String functionName, java.lang.String expression)Creates an sql function expression.Example:
sqlFunction("max", CN_ID) --> "MAX(id)"- Parameters:
functionName- the function name, will be translated to uppercaseexpression- the expression, may be null- Returns:
- the sql code
-
needSetLongWorkaround
boolean needSetLongWorkaround()
Checks whether we need a workaround for the (Ingres) setLong-Bug.- Returns:
- true if workaround needed
-
needTxForFetchsize
boolean needTxForFetchsize()
Checks for the (postgres) bug that fetchsize is ignored if not within a new transaction.- Returns:
- true if start tx
-
isConstraintException
boolean isConstraintException(java.sql.SQLException ex)
Determines whether exception is a constraint violation.- Parameters:
ex- the exception- Returns:
- true if constraint violation
-
isCommunicationLinkException
boolean isCommunicationLinkException(java.sql.SQLException ex)
Determines whether exception is a communication error.- Parameters:
ex- the exception- Returns:
- true if comlink down or alike
-
getMaxSize
int getMaxSize(SqlType sqlType)
Returns the maximum size for a given SQL-type.- Parameters:
sqlType- the SQL-type- Returns:
- the maximum size, 0 if unlimited, -1 if type without size
-
getMaxScale
int getMaxScale(SqlType sqlType, int size)
Returns the maximum scale for a given SQL-type and size.- Parameters:
sqlType- the SQL-typesize- the size, 0 if unlimited- Returns:
- the maximum scale, 0 if unlimited
-
getDefaultSize
int getDefaultSize(SqlType sqlType)
Gets the default size if no size given in model.- Parameters:
sqlType- the SQL-type- Returns:
- the default size, 0 if no default size
-
getDefaultSchema
java.lang.String getDefaultSchema()
Gets the default schema name.
Some backends store the objects in a default schema, if no explicit schema is given.- Returns:
- the defailt schema, null if none
-
getReservedWords
java.util.Set<java.lang.String> getReservedWords()
Gets the list of reserved words for this backend.- Returns:
- the list of reserved words
-
assertValidName
void assertValidName(SqlNameType nameType, java.lang.String name)
Asserts that given string is a valid name and usage.- Parameters:
nameType- the type/usage of the namename- the name- Throws:
BackendException- if invalid name
-
getBackendId
java.lang.String getBackendId(java.sql.Connection connection)
Determines the unique id or name used by the backend for a given connection.Useful to figure out the corresponding
ManagedConnectionfrom the backend's logfiles.- Parameters:
connection- the jdbc connection- Returns:
- the backend id, null if none
-
getModelMetaData
ModelMetaData getModelMetaData(java.sql.DatabaseMetaData[] metaData, java.lang.String[] schemas, java.lang.String... tableNames)
Retrieves the metadata.- Parameters:
metaData- the meta data for the whole databaseschemas- the optional schemas to filter tables, null if no filtertableNames- the tables of the model- Returns:
- the meta data, null if no such table
-
createColumnMetaData
ColumnMetaData createColumnMetaData(TableMetaData tableMetaData)
Creates a column meta data instance.- Parameters:
tableMetaData- the table meta data this column belongs to- Returns:
- the meta data
-
createTableMetaData
TableMetaData createTableMetaData(ModelMetaData metaData, java.lang.String tableName)
Creates a meta data instance.- Parameters:
metaData- the whole meta datatableName- the model's table name- Returns:
- the meta data
-
createIndexMetaData
IndexMetaData createIndexMetaData(TableMetaData tableMetaData)
Creates an index meta data instance.- Parameters:
tableMetaData- the table meta data this index belongs to- Returns:
- the meta data
-
createIndexColumnMetaData
IndexColumnMetaData createIndexColumnMetaData(IndexMetaData indexMetaData)
Creates an index column meta data instance.- Parameters:
indexMetaData- the meta meta data this column belongs to- Returns:
- the meta data
-
sqlTypeToString
java.lang.String sqlTypeToString(SqlType sqlType, int size)
Converts the java SQL-type to the database type name.- Parameters:
sqlType- the java sql typesize- the column's size- Returns:
- the corresponding type string
-
columnTypeToString
java.lang.String columnTypeToString(SqlType sqlType, int size, int scale)
Converts an sqltype, size and scale to a database type declaration.- Parameters:
sqlType- the SQL typesize- the sizescale- the scale- Returns:
- the type definition
-
columnTypeNullDefaultToString
java.lang.String columnTypeNullDefaultToString(java.lang.String columnName, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Converts an sqltype, size, scale, nullable and default value to a database type declaration.- Parameters:
columnName- the database column namesqlType- the JDBC sql typesize- the optional sizescale- the optional scalenullable- true if NULL, else NOT NULLdefaultValue- the optional default value- Returns:
- the SQL code
-
valueToLiteral
java.lang.String valueToLiteral(SqlType sqlType, java.lang.Object value)
Conberts a type and value to a literal string.- Parameters:
sqlType- the sql typevalue- the value- Returns:
- the constant
-
sqlCreateTableIntro
java.lang.String sqlCreateTableIntro(java.lang.String tableName, java.lang.String comment)Generates the first line of a CREATE TABLE statement.- Parameters:
tableName- the tablename with optional schema separated by a dotcomment- optional comment, null if none- Returns:
- the SQL code including the opening bracket
-
sqlCreateTableClosing
java.lang.String sqlCreateTableClosing(java.lang.String tableName, java.lang.String comment)Generates the last line of a CREATE TABLE statement.- Parameters:
tableName- the tablename with optional schema separated by a dotcomment- optional comment, null if none- Returns:
- the SQL code including the closing bracket
-
sqlCreateTableComment
java.lang.String sqlCreateTableComment(java.lang.String tableName, java.lang.String comment)Generates SQL code to create the comment for a table.- Parameters:
tableName- the table namecomment- optional comment, null if none- Returns:
- the SQL code, empty string if comment is created via
sqlCreateTableIntro(java.lang.String, java.lang.String)orsqlCreateTableClosing(java.lang.String, java.lang.String)
-
sqlAlterTableComment
java.lang.String sqlAlterTableComment(java.lang.String tableName, java.lang.String comment)Generates SQL code to alter the comment for a table.- Parameters:
tableName- the table namecomment- optional comment, null to clear- Returns:
- the SQL code
-
sqlCreateColumn
java.lang.String sqlCreateColumn(java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue, boolean primaryKey, boolean withTrailingComma)Generates the attribute definition of a CREATE TABLE statement.- Parameters:
columnName- 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 comma- Returns:
- the SQL code
-
isDefaultEqual
boolean isDefaultEqual(ColumnMetaData column, SqlType sqlType, java.lang.Object defaultValue)
Checks whether the column's default corresponds to the model's default value.- Parameters:
column- the column to inspectsqlType- the sql typedefaultValue- the model's default value- Returns:
- true if same
-
getMigrationStrategy
MigrationStrategy[] getMigrationStrategy(ColumnMetaData column, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)
Determines the best migration strategy.- Parameters:
column- old column meta datacolumnName- new column namecomment- new commentsqlType- new sql typesize- new sizescale- new scalenullable- new nullabledefaultValue- new default- Returns:
- the strategies in order to achieve the migration
-
sqlRenameTable
java.lang.String sqlRenameTable(java.lang.String tableName, java.lang.String newTableName)Generate sql code to rename a table.- Parameters:
tableName- the old tablename (with leading schema, if any)newTableName- the new tablename (without schema)- Returns:
- the SQL code
-
sqlRenameColumn
java.lang.String sqlRenameColumn(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName)Generates sql code to rename a column.- Parameters:
tableName- the tablenameoldColumnName- the old column namenewColumnName- the new column name- Returns:
- the SQL code, null if need full spec sqlRenameAndAlterColumnType below
-
sqlRenameIndex
java.lang.String sqlRenameIndex(java.lang.String tableName, java.lang.String oldIndexName, java.lang.String newIndexName)Generates sql code to rename an index.- Parameters:
tableName- the tablenameoldIndexName- the old column namenewIndexName- the new column name- Returns:
- the SQL code, null if not supported by the backend and we need to drop and create
-
sqlRenameAndAlterColumnType
java.lang.String sqlRenameAndAlterColumnType(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to rename a column.- Parameters:
tableName- 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 value- Returns:
- the SQL code
-
sqlAddColumn
java.lang.String sqlAddColumn(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to add a column.- Parameters:
tableName- 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 value- Returns:
- the SQL code
-
sqlDropColumn
java.lang.String sqlDropColumn(java.lang.String tableName, java.lang.String columnName)Generates sql code to drop a column.- Parameters:
tableName- the tablenamecolumnName- the new column name- Returns:
- the SQL code
-
sqlAlterColumnType
java.lang.String sqlAlterColumnType(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to change the datatype of a column.- Parameters:
tableName- 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 value- Returns:
- the SQL code
-
sqlUpdateToNotNull
java.lang.String sqlUpdateToNotNull(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Generates code to update a column to a non-null value.- Parameters:
tableName- the tablenamecolumnName- the column namesqlType- the sql typedefaultValue- the optional default value if defined in the model- Returns:
- the SQL code
-
sqlAlterColumnNullConstraint
java.lang.String sqlAlterColumnNullConstraint(java.lang.String tableName, java.lang.String columnName, boolean nullable)Generates sql code to change the null-constraint of a column.- Parameters:
tableName- the tablenamecolumnName- the new column namenullable- true if NULL, else NOT NULL- Returns:
- the SQL code, null if need
sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)
-
sqlAlterColumnDefault
java.lang.String sqlAlterColumnDefault(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Generates sql code to change the default value a column.- Parameters:
tableName- the tablenamecolumnName- the new column namesqlType- the JDBC sql typedefaultValue- the optional default value- Returns:
- the SQL code, null if need
sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)
-
sqlCreateColumnComment
java.lang.String sqlCreateColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Generates SQL code to create the comment for an attribute.- Parameters:
tableName- the table namecolumnName- the column namecomment- optional comment, null if none- Returns:
- the SQL code, empty string if comment is created via
sqlCreateColumn(java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object, boolean, boolean)
-
sqlCreateIndex
java.lang.String sqlCreateIndex(java.lang.String tableName, java.lang.String indexName, boolean unique, java.lang.String filterCondition, java.lang.String... columnNames)Generates the CREATE INDEX statement.- Parameters:
tableName- 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). Simple function-based indexes are also supported.- Returns:
- the SQL code
-
sqlDropIndex
java.lang.String sqlDropIndex(java.lang.String schemaName, java.lang.String tableNameWithoutSchema, java.lang.String indexName)Generates the DROP INDEX statement.- Parameters:
schemaName- the optional schema, null if nonetableNameWithoutSchema- the table name without the schemaindexName- the name of the index- Returns:
- the SQL code
-
sqlDropTable
java.lang.String sqlDropTable(java.lang.String schemaName, java.lang.String tableNameWithoutSchema)Generates the DROP TABLE statement.- Parameters:
schemaName- the optional schema, null if nonetableNameWithoutSchema- the table name without the schema- Returns:
- the SQL code
-
sqlCreateForeignKey
java.lang.String sqlCreateForeignKey(java.lang.String referencingTableName, java.lang.String referencingColumnName, java.lang.String referencedTableName, java.lang.String referencedColumnName, java.lang.String foreignKeyName, boolean composite)Generates the ALTER TABLE statement to add a foreign key constraint.- Parameters:
referencingTableName- the referencing foreign table namereferencingColumnName- the referencing foreign column namereferencedTableName- the referenced primary table namereferencedColumnName- the referenced primary column nameforeignKeyName- the name of the foreign keycomposite- true if referencing table is a component of the referenced table- Returns:
- the SQL code
-
sqlDropForeignKey
java.lang.String sqlDropForeignKey(java.lang.String referencingTableName, java.lang.String foreignKeyName)Generates the sql statement to drop a foreign key constraint.- Parameters:
referencingTableName- the referencing foreign table nameforeignKeyName- the name of the foreign key- Returns:
- the SQL code
-
sqlAlterColumnComment
java.lang.String sqlAlterColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Generates SQL code to alter the comment for an attribute.- Parameters:
tableName- the table namecolumnName- the column namecomment- optional comment, null to clear- Returns:
- the SQL code, null if use
sqlRenameAndAlterColumnType(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)instead
-
sqlJoinSelects
void sqlJoinSelects(JoinType type, boolean addColumns, java.lang.StringBuilder select, java.lang.String joinSelect, java.lang.String joinSelectIdAlias, java.lang.String joinAlias, java.lang.String join)
Generate SQL code for joining a table to an existing select.- Parameters:
type- 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 clause
-
sqlJoinSelects
java.lang.String sqlJoinSelects(JoinType type, boolean addColumns, java.lang.String select, java.lang.String joinSelect, java.lang.String joinSelectIdAlias, java.lang.String joinAlias, java.lang.String join)
Generate SQL code for joining a table to an existing select.- Parameters:
type- 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 clause- Returns:
- the select statement
-
jdbcTypeToSqlType
SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
Converts the JDBC data type integer to a tentackle backend SqlTypes.There may be more than one sqltype returned!
- Parameters:
jdbcType- the jdbc data typesize- the column sizescale- the column's scale- Returns:
- the SqlTypes, empty array if no mapping available or no exact match (not generated by TT)
- See Also:
Types
-
getTableMetaData
TableMetaData getTableMetaData(ModelMetaData modelMetaData, java.lang.String tableName)
Gets the table meta data for a given table name.- Parameters:
modelMetaData- the model the table belongs totableName- the model's table name- Returns:
- the table data
-
toQuotedString
java.lang.String toQuotedString(java.lang.String str)
Converts a string to a string enclosed in single quotes.- Parameters:
str- the string- Returns:
- the quoted string
-
optimizeSql
java.lang.String optimizeSql(java.lang.String sql)
Optimize SQL code.
Replace WHERE 1=1 AND/OR to WHERE. Any remaining WHERE 1=1 will be removed too. If you don't want your statements getting optimized, use lowercase for those keywords.- Parameters:
sql- the original sql code- Returns:
- the optimized sql code
-
isReleaseSavepointSupported
boolean isReleaseSavepointSupported()
Returns whether the backend supports releasing savepoints explicitly. If not, the savepoints are released when the transaction finishs.- Returns:
- true if release is supported, else false
-
isClobSupported
boolean isClobSupported()
Returns whether the backend support CLOB types.
If not, it will be emulated as VARCHAR with the maximum possible size.- Returns:
- true if supported, false if treat as varchar
-
isFunctionBasedIndexSupported
boolean isFunctionBasedIndexSupported()
Returns whether function based indexes are supported.- Returns:
- true if supported
-
isFilteredIndexSupported
boolean isFilteredIndexSupported()
Returns whether backend supports filtered indexes.- Returns:
- true if supported, false if model will raise an error if filtered index is used
-
setDropIfExistsEnabled
void setDropIfExistsEnabled(boolean dropIfExists)
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 (seeisTemporaryName(String)in order to be ignored by the migrator.- Parameters:
dropIfExists- true if use IF EXISTS if the backend supports it
-
isDropIfExistsEnabled
boolean isDropIfExistsEnabled()
Returns whether backend should add IF EXISTS for generated DROPs.- Returns:
- true if IF EXISTS is turned on and supported, false if not supported or turned off
-
toInternalType
java.lang.String toInternalType(java.lang.String sqlTypeName)
Converts a backend specific type name to an internal name used by driver specific methods.- Parameters:
sqlTypeName- the original type used in SQL scripts- Returns:
- the JDBC internal name
-
isArrayOperatorSupported
boolean isArrayOperatorSupported(java.lang.String operator)
Returns whether the backend supports given array operator.- Parameters:
operator- the array operator- Returns:
- true if supported
-
setArray
void setArray(java.sql.PreparedStatement statement, int pos, SqlType type, java.util.Collection<?> elements, java.lang.String operator) throws java.sql.SQLExceptionSets an array parameter in a prepared statement.- Parameters:
statement- the prepared statementpos- the parameter position (starting at 1)type- the element's SQL typeelements- the elements to be converted to an array parameteroperator- the array operator- Throws:
java.sql.SQLException
-
-