- java.lang.Object
-
- org.tentackle.sql.AbstractBackend
-
- All Implemented Interfaces:
Backend
- Direct Known Subclasses:
AbstractSql92Backend
public abstract class AbstractBackend extends java.lang.Object implements Backend
Abstract parent class for backends.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringTYPE_BIGINTprotected static java.lang.StringTYPE_BITprotected static java.lang.StringTYPE_BLOBprotected static java.lang.StringTYPE_BOOLprotected static java.lang.StringTYPE_BOOLEANprotected static java.lang.StringTYPE_BYTEprotected static java.lang.StringTYPE_BYTEAprotected static java.lang.StringTYPE_CHAR_1protected static java.lang.StringTYPE_CLOBprotected static java.lang.StringTYPE_DATEprotected static java.lang.StringTYPE_DATETIMEprotected static java.lang.StringTYPE_DATETIME_YEAR_TO_SECONDprotected static java.lang.StringTYPE_DECIMALprotected static java.lang.StringTYPE_DECIMAL_19protected static java.lang.StringTYPE_DOUBLEprotected static java.lang.StringTYPE_FLOATprotected static java.lang.StringTYPE_FLOAT4protected static java.lang.StringTYPE_FLOAT8protected static java.lang.StringTYPE_INTprotected static java.lang.StringTYPE_INT2protected static java.lang.StringTYPE_INT4protected static java.lang.StringTYPE_INT8protected static java.lang.StringTYPE_INTEGERprotected static java.lang.StringTYPE_NCHAR_1protected static java.lang.StringTYPE_NUMBERprotected static java.lang.StringTYPE_NUMBER_1protected static java.lang.StringTYPE_NUMBER_10protected static java.lang.StringTYPE_NUMBER_19protected static java.lang.StringTYPE_NUMBER_5protected static java.lang.StringTYPE_NVARCHARprotected static java.lang.StringTYPE_NVARCHAR_MAXprotected static java.lang.StringTYPE_REALprotected static java.lang.StringTYPE_SMALLFLOATprotected static java.lang.StringTYPE_SMALLINTprotected static java.lang.StringTYPE_TEXTprotected static java.lang.StringTYPE_TIMEprotected static java.lang.StringTYPE_TIMESTAMPprotected static java.lang.StringTYPE_TINYINTprotected static java.lang.StringTYPE_VARBINARY_MAXprotected static java.lang.StringTYPE_VARCHAR-
Fields inherited from interface org.tentackle.sql.Backend
SQL_ALLSTAR, SQL_ALTER_COLUMN, SQL_ALTER_INDEX, 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 Summary
Constructors Constructor Description AbstractBackend()
-
Method Summary
All Methods Instance Methods Concrete 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.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.protected java.lang.StringcreatePassword(char[] password)Creates a password string from a password char array.
Unfortunately,DriverManager.getConnection(String, String, String)requires the password as a string.TableMetaDatacreateTableMetaData(ModelMetaData modelMetaData, java.lang.String tableName)Creates a meta data instance.protected java.lang.StringextractWhereClause(java.lang.String sql, int whereOffset)Extracts the where clause from a given sql.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.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.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.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.protected booleanisDropIfExistsSupported()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.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.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.protected java.lang.StringnormalizeDefault(java.lang.String str)Normalize the default string to compare.java.lang.StringoptimizeSql(java.lang.String sql)Optimize SQL code.
Replace WHERE 1=1 AND/OR to WHERE.voidsetDropIfExistsEnabled(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 (seeBackend.isTemporaryName(String)in order to be ignored by the migrator.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.StringsqlCreateIndex(java.lang.String tableName, java.lang.String indexName, boolean unique, java.lang.String filterCondition, java.lang.String... columnNames)Generates the CREATE INDEX statement.protected java.lang.StringsqlCreateTableAttributeWithoutComment(java.lang.String columnName, 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.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.protected java.lang.StringsqlCreateTableIntroWithoutComment(java.lang.String tableName)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.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.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.java.lang.StringtoQuotedString(java.lang.String str)Converts a string to a string enclosed in single quotes.java.lang.StringtoString()java.lang.StringvalueToLiteral(SqlType sqlType, java.lang.Object value)Conberts a type and value to a literal string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.tentackle.sql.Backend
buildSelectSql, getBackendId, getDriverClassName, getName, getReservedWords, isMatchingUrl, setLeadingSelectParameters, setTrailingSelectParameters, sqlCreateForeignKey, sqlDropForeignKey, sqlNextFromSequene, supportsSequences
-
-
-
-
Field Detail
-
TYPE_BIGINT
protected static final java.lang.String TYPE_BIGINT
- See Also:
- Constant Field Values
-
TYPE_BIT
protected static final java.lang.String TYPE_BIT
- See Also:
- Constant Field Values
-
TYPE_BLOB
protected static final java.lang.String TYPE_BLOB
- See Also:
- Constant Field Values
-
TYPE_CLOB
protected static final java.lang.String TYPE_CLOB
- See Also:
- Constant Field Values
-
TYPE_BOOL
protected static final java.lang.String TYPE_BOOL
- See Also:
- Constant Field Values
-
TYPE_BOOLEAN
protected static final java.lang.String TYPE_BOOLEAN
- See Also:
- Constant Field Values
-
TYPE_BYTEA
protected static final java.lang.String TYPE_BYTEA
- See Also:
- Constant Field Values
-
TYPE_BYTE
protected static final java.lang.String TYPE_BYTE
- See Also:
- Constant Field Values
-
TYPE_CHAR_1
protected static final java.lang.String TYPE_CHAR_1
- See Also:
- Constant Field Values
-
TYPE_DATE
protected static final java.lang.String TYPE_DATE
- See Also:
- Constant Field Values
-
TYPE_DATETIME
protected static final java.lang.String TYPE_DATETIME
- See Also:
- Constant Field Values
-
TYPE_DATETIME_YEAR_TO_SECOND
protected static final java.lang.String TYPE_DATETIME_YEAR_TO_SECOND
- See Also:
- Constant Field Values
-
TYPE_DECIMAL
protected static final java.lang.String TYPE_DECIMAL
- See Also:
- Constant Field Values
-
TYPE_DECIMAL_19
protected static final java.lang.String TYPE_DECIMAL_19
- See Also:
- Constant Field Values
-
TYPE_DOUBLE
protected static final java.lang.String TYPE_DOUBLE
- See Also:
- Constant Field Values
-
TYPE_FLOAT
protected static final java.lang.String TYPE_FLOAT
- See Also:
- Constant Field Values
-
TYPE_FLOAT4
protected static final java.lang.String TYPE_FLOAT4
- See Also:
- Constant Field Values
-
TYPE_FLOAT8
protected static final java.lang.String TYPE_FLOAT8
- See Also:
- Constant Field Values
-
TYPE_INT
protected static final java.lang.String TYPE_INT
- See Also:
- Constant Field Values
-
TYPE_INT2
protected static final java.lang.String TYPE_INT2
- See Also:
- Constant Field Values
-
TYPE_INT4
protected static final java.lang.String TYPE_INT4
- See Also:
- Constant Field Values
-
TYPE_INT8
protected static final java.lang.String TYPE_INT8
- See Also:
- Constant Field Values
-
TYPE_INTEGER
protected static final java.lang.String TYPE_INTEGER
- See Also:
- Constant Field Values
-
TYPE_NCHAR_1
protected static final java.lang.String TYPE_NCHAR_1
- See Also:
- Constant Field Values
-
TYPE_NUMBER
protected static final java.lang.String TYPE_NUMBER
- See Also:
- Constant Field Values
-
TYPE_NUMBER_1
protected static final java.lang.String TYPE_NUMBER_1
- See Also:
- Constant Field Values
-
TYPE_NUMBER_5
protected static final java.lang.String TYPE_NUMBER_5
- See Also:
- Constant Field Values
-
TYPE_NUMBER_10
protected static final java.lang.String TYPE_NUMBER_10
- See Also:
- Constant Field Values
-
TYPE_NUMBER_19
protected static final java.lang.String TYPE_NUMBER_19
- See Also:
- Constant Field Values
-
TYPE_NVARCHAR
protected static final java.lang.String TYPE_NVARCHAR
- See Also:
- Constant Field Values
-
TYPE_NVARCHAR_MAX
protected static final java.lang.String TYPE_NVARCHAR_MAX
- See Also:
- Constant Field Values
-
TYPE_REAL
protected static final java.lang.String TYPE_REAL
- See Also:
- Constant Field Values
-
TYPE_TEXT
protected static final java.lang.String TYPE_TEXT
- See Also:
- Constant Field Values
-
TYPE_TIME
protected static final java.lang.String TYPE_TIME
- See Also:
- Constant Field Values
-
TYPE_TIMESTAMP
protected static final java.lang.String TYPE_TIMESTAMP
- See Also:
- Constant Field Values
-
TYPE_TINYINT
protected static final java.lang.String TYPE_TINYINT
- See Also:
- Constant Field Values
-
TYPE_SMALLFLOAT
protected static final java.lang.String TYPE_SMALLFLOAT
- See Also:
- Constant Field Values
-
TYPE_SMALLINT
protected static final java.lang.String TYPE_SMALLINT
- See Also:
- Constant Field Values
-
TYPE_VARBINARY_MAX
protected static final java.lang.String TYPE_VARBINARY_MAX
- See Also:
- Constant Field Values
-
TYPE_VARCHAR
protected static final java.lang.String TYPE_VARCHAR
- See Also:
- Constant Field Values
-
-
Method Detail
-
isMatchingName
public boolean isMatchingName(java.lang.String name)
Description copied from interface:BackendChecks whether the backend belongs to the given name.- Specified by:
isMatchingNamein interfaceBackend- Parameters:
name- the backend's name- Returns:
- true if matches
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
createConnection
public java.sql.Connection createConnection(java.lang.String url, java.lang.String username, char[] password) throws java.sql.SQLExceptionDescription copied from interface:BackendCreates a jdbc connection.- Specified by:
createConnectionin interfaceBackend- Parameters:
url- the jdbc urlusername- the usernamepassword- the password- Returns:
- the created connection
- Throws:
java.sql.SQLException- if connection could not be established
-
createPassword
protected java.lang.String createPassword(char[] password)
Creates a password string from a password char array.
Unfortunately,DriverManager.getConnection(String, String, String)requires the password as a string. This method creates a string from a char array and optionally decrypts it. Encrypted passwords are detected by a leading~. If an unencrypted password must begin with a~, a double~~must be used.- Parameters:
password- the probably encrypted password- Returns:
- the cleartext password
-
getMetaData
public java.sql.DatabaseMetaData[] getMetaData(BackendInfo backendInfo) throws java.sql.SQLException
Description copied from interface:BackendGets the metadata from the backend.Important: the connection of the metadata is open!
- Specified by:
getMetaDatain interfaceBackend- 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
public java.util.List<DatabaseMetaDataTableHeader> getTableHeaders(java.sql.DatabaseMetaData metaData) throws java.sql.SQLException
Description copied from interface:BackendGets all table headers for a given metadata.- Specified by:
getTableHeadersin interfaceBackend- Parameters:
metaData- the database metadata- Returns:
- the list of table headers
- Throws:
java.sql.SQLException- if failed
-
isTemporaryName
public boolean isTemporaryName(java.lang.String name)
Description copied from interface:BackendChecks 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.- Specified by:
isTemporaryNamein interfaceBackend- Parameters:
name- the name- Returns:
- true temporary (invalid) name
-
isReservedTableName
public boolean isReservedTableName(java.lang.String name)
Description copied from interface:BackendChecks whether this a reserved table name for this backend.
Applies only to tables. Not to be mixed up withBackend.getReservedWords().
Useful to avoid conflicts with naming conventions for backend specific things, such as snapshots.- Specified by:
isReservedTableNamein interfaceBackend- Parameters:
name- the table name- Returns:
- true if reserved by backend
-
isReservedSchemaName
public boolean isReservedSchemaName(java.lang.String name)
Description copied from interface:BackendChecks whether this is a reserved schema name for this backend.- Specified by:
isReservedSchemaNamein interfaceBackend- Parameters:
name- the schema name- Returns:
- true if reserved by backend
-
getEmptyString
public java.lang.String getEmptyString()
Description copied from interface:BackendGets 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.
- Specified by:
getEmptyStringin interfaceBackend- Returns:
- the empty string (never null)
-
sqlAsBeforeTableAlias
public java.lang.String sqlAsBeforeTableAlias()
Description copied from interface:BackendGets the string before the table alias.
In most databases the " AS " is optional and some don't accept it all.- Specified by:
sqlAsBeforeTableAliasin interfaceBackend- Returns:
- the as-string
-
needAliasForSubselect
public boolean needAliasForSubselect()
Description copied from interface:BackendReturns whether backend needs an alias for a subselect.- Specified by:
needAliasForSubselectin interfaceBackend- Returns:
- true if subselect needs an alias.
-
sqlRequiresExtraCommit
public boolean sqlRequiresExtraCommit()
Description copied from interface:BackendAccording to the JDBC-specsConnection.setAutoCommit(boolean)(true) should commit, but some backends require an extraConnection.commit().- Specified by:
sqlRequiresExtraCommitin interfaceBackend- Returns:
- true if the database needs an extra commit
-
sqlResultSetIsClosedSupported
public boolean sqlResultSetIsClosedSupported()
Description copied from interface:BackendDetermines whether the jdbc driver supportsResultSet.isClosed().- Specified by:
sqlResultSetIsClosedSupportedin interfaceBackend- Returns:
- true if the driver supports it
-
sqlComment
public java.lang.String sqlComment(java.lang.String text)
Description copied from interface:BackendCreate comment sql code that is interpreted as a comment by the backend.- Specified by:
sqlCommentin interfaceBackend- Parameters:
text- any text, single or multiline- Returns:
- the comment, null if text was null
-
sqlJoin
public java.lang.String sqlJoin(JoinType type, java.lang.String joinedTableName, java.lang.String joinedTableAlias, java.lang.String join)
Description copied from interface:BackendCreates a join clause.
-
sqlFunction
public java.lang.String sqlFunction(java.lang.String functionName, java.lang.String expression)Description copied from interface:BackendCreates an sql function expression.Example:
sqlFunction("max", CN_ID) --> "MAX(id)"- Specified by:
sqlFunctionin interfaceBackend- Parameters:
functionName- the function name, will be translated to uppercaseexpression- the expression, may be null- Returns:
- the sql code
-
getCoalesceKeyword
public java.lang.String getCoalesceKeyword()
Description copied from interface:BackendGets the keyword for the COALESCE function.- Specified by:
getCoalesceKeywordin interfaceBackend- Returns:
- the keyword
-
allowsExpressionsReferringToTablesBeingUpdated
public boolean allowsExpressionsReferringToTablesBeingUpdated()
Description copied from interface:BackendDetermines whether backend allows expressions referring to tables being updated.- Specified by:
allowsExpressionsReferringToTablesBeingUpdatedin interfaceBackend- Returns:
- true if allowed
-
needSetLongWorkaround
public boolean needSetLongWorkaround()
Description copied from interface:BackendChecks whether we need a workaround for the (Ingres) setLong-Bug.- Specified by:
needSetLongWorkaroundin interfaceBackend- Returns:
- true if workaround needed
-
needTxForFetchsize
public boolean needTxForFetchsize()
Description copied from interface:BackendChecks for the (postgres) bug that fetchsize is ignored if not within a new transaction.- Specified by:
needTxForFetchsizein interfaceBackend- Returns:
- true if start tx
-
isConstraintException
public boolean isConstraintException(java.sql.SQLException ex)
Description copied from interface:BackendDetermines whether exception is a constraint violation.- Specified by:
isConstraintExceptionin interfaceBackend- Parameters:
ex- the exception- Returns:
- true if constraint violation
-
isCommunicationLinkException
public boolean isCommunicationLinkException(java.sql.SQLException ex)
Description copied from interface:BackendDetermines whether exception is a communication error.- Specified by:
isCommunicationLinkExceptionin interfaceBackend- Parameters:
ex- the exception- Returns:
- true if comlink down or alike
-
getMaxSize
public int getMaxSize(SqlType sqlType)
Description copied from interface:BackendReturns the maximum size for a given SQL-type.- Specified by:
getMaxSizein interfaceBackend- Parameters:
sqlType- the SQL-type- Returns:
- the maximum size, 0 if unlimited, -1 if type without size
-
getMaxScale
public int getMaxScale(SqlType sqlType, int size)
Description copied from interface:BackendReturns the maximum scale for a given SQL-type and size.- Specified by:
getMaxScalein interfaceBackend- Parameters:
sqlType- the SQL-typesize- the size, 0 if unlimited- Returns:
- the maximum scale, 0 if unlimited
-
getDefaultSize
public int getDefaultSize(SqlType sqlType)
Description copied from interface:BackendGets the default size if no size given in model.- Specified by:
getDefaultSizein interfaceBackend- Parameters:
sqlType- the SQL-type- Returns:
- the default size, 0 if no default size
-
getDefaultSchema
public java.lang.String getDefaultSchema()
Description copied from interface:BackendGets the default schema name.
Some backends store the objects in a default schema, if no explicit schema is given.- Specified by:
getDefaultSchemain interfaceBackend- Returns:
- the defailt schema, null if none
-
getModelMetaData
public ModelMetaData getModelMetaData(java.sql.DatabaseMetaData[] metaData, java.lang.String[] schemas, java.lang.String... tableNames)
Description copied from interface:BackendRetrieves the metadata.- Specified by:
getModelMetaDatain interfaceBackend- 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
-
getTableMetaData
public TableMetaData getTableMetaData(ModelMetaData modelMetaData, java.lang.String tableName)
Description copied from interface:BackendGets the table meta data for a given table name.- Specified by:
getTableMetaDatain interfaceBackend- Parameters:
modelMetaData- the model the table belongs totableName- the model's table name- Returns:
- the table data
-
createTableMetaData
public TableMetaData createTableMetaData(ModelMetaData modelMetaData, java.lang.String tableName)
Description copied from interface:BackendCreates a meta data instance.- Specified by:
createTableMetaDatain interfaceBackend- Parameters:
modelMetaData- the whole meta datatableName- the model's table name- Returns:
- the meta data
-
createColumnMetaData
public ColumnMetaData createColumnMetaData(TableMetaData tableMetaData)
Description copied from interface:BackendCreates a column meta data instance.- Specified by:
createColumnMetaDatain interfaceBackend- Parameters:
tableMetaData- the table meta data this column belongs to- Returns:
- the meta data
-
createIndexMetaData
public IndexMetaData createIndexMetaData(TableMetaData tableMetaData)
Description copied from interface:BackendCreates an index meta data instance.- Specified by:
createIndexMetaDatain interfaceBackend- Parameters:
tableMetaData- the table meta data this index belongs to- Returns:
- the meta data
-
createIndexColumnMetaData
public IndexColumnMetaData createIndexColumnMetaData(IndexMetaData indexMetaData)
Description copied from interface:BackendCreates an index column meta data instance.- Specified by:
createIndexColumnMetaDatain interfaceBackend- Parameters:
indexMetaData- the meta meta data this column belongs to- Returns:
- the meta data
-
sqlCreateTableIntro
public java.lang.String sqlCreateTableIntro(java.lang.String tableName, java.lang.String comment)Description copied from interface:BackendGenerates the first line of a CREATE TABLE statement.- Specified by:
sqlCreateTableIntroin interfaceBackend- Parameters:
tableName- the tablename with optional schema separated by a dotcomment- optional comment, null if none- Returns:
- the SQL code including the opening bracket
-
sqlCreateTableIntroWithoutComment
protected java.lang.String sqlCreateTableIntroWithoutComment(java.lang.String tableName)
Generates the first line of a CREATE TABLE statement.- Parameters:
tableName- the tablename with optional schema separated by a dot- Returns:
- the SQL code including the opening bracket
-
sqlCreateTableClosing
public java.lang.String sqlCreateTableClosing(java.lang.String tableName, java.lang.String comment)Description copied from interface:BackendGenerates the last line of a CREATE TABLE statement.- Specified by:
sqlCreateTableClosingin interfaceBackend- 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
public java.lang.String sqlCreateTableComment(java.lang.String tableName, java.lang.String comment)Description copied from interface:BackendGenerates SQL code to create the comment for a table.- Specified by:
sqlCreateTableCommentin interfaceBackend- Parameters:
tableName- the table namecomment- optional comment, null if none- Returns:
- the SQL code, empty string if comment is created via
Backend.sqlCreateTableIntro(java.lang.String, java.lang.String)orBackend.sqlCreateTableClosing(java.lang.String, java.lang.String)
-
sqlAlterTableComment
public java.lang.String sqlAlterTableComment(java.lang.String tableName, java.lang.String comment)Description copied from interface:BackendGenerates SQL code to alter the comment for a table.- Specified by:
sqlAlterTableCommentin interfaceBackend- Parameters:
tableName- the table namecomment- optional comment, null to clear- Returns:
- the SQL code
-
columnTypeToString
public java.lang.String columnTypeToString(SqlType sqlType, int size, int scale)
Description copied from interface:BackendConverts an sqltype, size and scale to a database type declaration.- Specified by:
columnTypeToStringin interfaceBackend- Parameters:
sqlType- the SQL typesize- the sizescale- the scale- Returns:
- the type definition
-
columnTypeNullDefaultToString
public java.lang.String columnTypeNullDefaultToString(java.lang.String columnName, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Description copied from interface:BackendConverts an sqltype, size, scale, nullable and default value to a database type declaration.- Specified by:
columnTypeNullDefaultToStringin interfaceBackend- 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
public java.lang.String valueToLiteral(SqlType sqlType, java.lang.Object value)
Description copied from interface:BackendConberts a type and value to a literal string.- Specified by:
valueToLiteralin interfaceBackend- Parameters:
sqlType- the sql typevalue- the value- Returns:
- the constant
-
sqlCreateColumn
public 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)Description copied from interface:BackendGenerates the attribute definition of a CREATE TABLE statement.- Specified by:
sqlCreateColumnin interfaceBackend- 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
public boolean isDefaultEqual(ColumnMetaData column, SqlType sqlType, java.lang.Object defaultValue)
Description copied from interface:BackendChecks whether the column's default corresponds to the model's default value.- Specified by:
isDefaultEqualin interfaceBackend- Parameters:
column- the column to inspectsqlType- the sql typedefaultValue- the model's default value- Returns:
- true if same
-
normalizeDefault
protected java.lang.String normalizeDefault(java.lang.String str)
Normalize the default string to compare.- Parameters:
str- the default value as a string, may be null- Returns:
- the normalized value, never null
-
getMigrationStrategy
public MigrationStrategy[] getMigrationStrategy(ColumnMetaData column, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)
Description copied from interface:BackendDetermines the best migration strategy.- Specified by:
getMigrationStrategyin interfaceBackend- 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
public java.lang.String sqlRenameTable(java.lang.String tableName, java.lang.String newTableName)Description copied from interface:BackendGenerate sql code to rename a table.- Specified by:
sqlRenameTablein interfaceBackend- Parameters:
tableName- the old tablename (with leading schema, if any)newTableName- the new tablename (without schema)- Returns:
- the SQL code
-
sqlRenameColumn
public java.lang.String sqlRenameColumn(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName)Description copied from interface:BackendGenerates sql code to rename a column.- Specified by:
sqlRenameColumnin interfaceBackend- Parameters:
tableName- the tablenameoldColumnName- the old column namenewColumnName- the new column name- Returns:
- the SQL code, null if need full spec sqlRenameAndAlterColumnType below
-
sqlRenameIndex
public java.lang.String sqlRenameIndex(java.lang.String tableName, java.lang.String oldIndexName, java.lang.String newIndexName)Description copied from interface:BackendGenerates sql code to rename an index.- Specified by:
sqlRenameIndexin interfaceBackend- 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
public 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)Description copied from interface:BackendGenerates sql code to rename a column.- Specified by:
sqlRenameAndAlterColumnTypein interfaceBackend- 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
public 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)Description copied from interface:BackendGenerates sql code to add a column.- Specified by:
sqlAddColumnin interfaceBackend- 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
public java.lang.String sqlDropColumn(java.lang.String tableName, java.lang.String columnName)Description copied from interface:BackendGenerates sql code to drop a column.- Specified by:
sqlDropColumnin interfaceBackend- Parameters:
tableName- the tablenamecolumnName- the new column name- Returns:
- the SQL code
-
sqlAlterColumnType
public 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)Description copied from interface:BackendGenerates sql code to change the datatype of a column.- Specified by:
sqlAlterColumnTypein interfaceBackend- 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
-
sqlAlterColumnNullConstraint
public java.lang.String sqlAlterColumnNullConstraint(java.lang.String tableName, java.lang.String columnName, boolean nullable)Description copied from interface:BackendGenerates sql code to change the null-constraint of a column.- Specified by:
sqlAlterColumnNullConstraintin interfaceBackend- Parameters:
tableName- the tablenamecolumnName- the new column namenullable- true if NULL, else NOT NULL- Returns:
- the SQL code, null if need
Backend.sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)
-
sqlUpdateToNotNull
public java.lang.String sqlUpdateToNotNull(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Description copied from interface:BackendGenerates code to update a column to a non-null value.- Specified by:
sqlUpdateToNotNullin interfaceBackend- Parameters:
tableName- the tablenamecolumnName- the column namesqlType- the sql typedefaultValue- the optional default value if defined in the model- Returns:
- the SQL code
-
sqlAlterColumnDefault
public java.lang.String sqlAlterColumnDefault(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Description copied from interface:BackendGenerates sql code to change the default value a column.- Specified by:
sqlAlterColumnDefaultin interfaceBackend- Parameters:
tableName- the tablenamecolumnName- the new column namesqlType- the JDBC sql typedefaultValue- the optional default value- Returns:
- the SQL code, null if need
Backend.sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)
-
sqlCreateTableAttributeWithoutComment
protected java.lang.String sqlCreateTableAttributeWithoutComment(java.lang.String columnName, 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 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 comma- Returns:
- the SQL code
-
sqlCreateColumnComment
public java.lang.String sqlCreateColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Description copied from interface:BackendGenerates SQL code to create the comment for an attribute.- Specified by:
sqlCreateColumnCommentin interfaceBackend- Parameters:
tableName- the table namecolumnName- the column namecomment- optional comment, null if none- Returns:
- the SQL code, empty string if comment is created via
Backend.sqlCreateColumn(java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object, boolean, boolean)
-
sqlAlterColumnComment
public java.lang.String sqlAlterColumnComment(java.lang.String tableName, java.lang.String columnName, java.lang.String comment)Description copied from interface:BackendGenerates SQL code to alter the comment for an attribute.- Specified by:
sqlAlterColumnCommentin interfaceBackend- Parameters:
tableName- the table namecolumnName- the column namecomment- optional comment, null to clear- Returns:
- the SQL code, null if use
Backend.sqlRenameAndAlterColumnType(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)instead
-
sqlTypeToString
public java.lang.String sqlTypeToString(SqlType sqlType, int size)
Description copied from interface:BackendConverts the java SQL-type to the database type name.- Specified by:
sqlTypeToStringin interfaceBackend- Parameters:
sqlType- the java sql typesize- the column's size- Returns:
- the corresponding type string
-
sqlCreateIndex
public java.lang.String sqlCreateIndex(java.lang.String tableName, java.lang.String indexName, boolean unique, java.lang.String filterCondition, java.lang.String... columnNames)Description copied from interface:BackendGenerates the CREATE INDEX statement.- Specified by:
sqlCreateIndexin interfaceBackend- 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
public java.lang.String sqlDropIndex(java.lang.String schemaName, java.lang.String tableNameWithoutSchema, java.lang.String indexName)Description copied from interface:BackendGenerates the DROP INDEX statement.- Specified by:
sqlDropIndexin interfaceBackend- Parameters:
schemaName- the optional schema, null if nonetableNameWithoutSchema- the table name without the schemaindexName- the name of the index- Returns:
- the SQL code
-
sqlDropTable
public java.lang.String sqlDropTable(java.lang.String schemaName, java.lang.String tableNameWithoutSchema)Description copied from interface:BackendGenerates the DROP TABLE statement.- Specified by:
sqlDropTablein interfaceBackend- Parameters:
schemaName- the optional schema, null if nonetableNameWithoutSchema- the table name without the schema- Returns:
- the SQL code
-
sqlJoinSelects
public 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)
Description copied from interface:BackendGenerate SQL code for joining a table to an existing select.- Specified by:
sqlJoinSelectsin interfaceBackend- 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
-
extractWhereClause
protected java.lang.String extractWhereClause(java.lang.String sql, int whereOffset)Extracts the where clause from a given sql.- Parameters:
sql- the sql statementwhereOffset- the location of WHERE in sql- Returns:
- the where clause without the keyword WHERE
-
assertValidName
public void assertValidName(SqlNameType nameType, java.lang.String name)
Description copied from interface:BackendAsserts that given string is a valid name and usage.- Specified by:
assertValidNamein interfaceBackend- Parameters:
nameType- the type/usage of the namename- the name
-
jdbcTypeToSqlType
public SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
Description copied from interface:BackendConverts the JDBC data type integer to a tentackle backend SqlTypes.There may be more than one sqltype returned!
- Specified by:
jdbcTypeToSqlTypein interfaceBackend- 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
-
toQuotedString
public java.lang.String toQuotedString(java.lang.String str)
Description copied from interface:BackendConverts a string to a string enclosed in single quotes.- Specified by:
toQuotedStringin interfaceBackend- Parameters:
str- the string- Returns:
- the quoted string
-
optimizeSql
public java.lang.String optimizeSql(java.lang.String sql)
Description copied from interface:BackendOptimize 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.- Specified by:
optimizeSqlin interfaceBackend- Parameters:
sql- the original sql code- Returns:
- the optimized sql code
-
buildSelectSql
public java.lang.String buildSelectSql(java.lang.String sql, boolean writeLock, int limit, int offset)Description copied from interface:BackendCreates 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.- Specified by:
buildSelectSqlin interfaceBackend- 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
-
sqlJoinSelects
public 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)
Description copied from interface:BackendGenerate SQL code for joining a table to an existing select.- Specified by:
sqlJoinSelectsin interfaceBackend- 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
-
isReleaseSavepointSupported
public boolean isReleaseSavepointSupported()
Description copied from interface:BackendReturns whether the backend supports releasing savepoints explicitly. If not, the savepoints are released when the transaction finishs.- Specified by:
isReleaseSavepointSupportedin interfaceBackend- Returns:
- true if release is supported, else false
-
isClobSupported
public boolean isClobSupported()
Description copied from interface:BackendReturns whether the backend support CLOB types.
If not, it will be emulated as VARCHAR with the maximum possible size.- Specified by:
isClobSupportedin interfaceBackend- Returns:
- true if supported, false if treat as varchar
-
isFunctionBasedIndexSupported
public boolean isFunctionBasedIndexSupported()
Description copied from interface:BackendReturns whether function based indexes are supported.- Specified by:
isFunctionBasedIndexSupportedin interfaceBackend- Returns:
- true if supported
-
isFilteredIndexSupported
public boolean isFilteredIndexSupported()
Description copied from interface:BackendReturns whether backend supports filtered indexes.- Specified by:
isFilteredIndexSupportedin interfaceBackend- Returns:
- true if supported, false if model will raise an error if filtered index is used
-
setDropIfExistsEnabled
public void setDropIfExistsEnabled(boolean dropIfExistsEnabled)
Description copied from interface:BackendSome 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 (seeBackend.isTemporaryName(String)in order to be ignored by the migrator.- Specified by:
setDropIfExistsEnabledin interfaceBackend- Parameters:
dropIfExistsEnabled- true if use IF EXISTS if the backend supports it
-
isDropIfExistsEnabled
public boolean isDropIfExistsEnabled()
Description copied from interface:BackendReturns whether backend should add IF EXISTS for generated DROPs.- Specified by:
isDropIfExistsEnabledin interfaceBackend- Returns:
- true if IF EXISTS is turned on and supported, false if not supported or turned off
-
isDropIfExistsSupported
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.- Returns:
- true if supported
-
-