java.lang.Object
org.tentackle.sql.backends.AbstractBackend
org.tentackle.sql.backends.AbstractSql92Backend
- All Implemented Interfaces:
Backend
- Direct Known Subclasses:
AbstractSql2003Backend,H2,Informix,MySql,Postgres
Common to all SQL92 backends.
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]array of reserved words.static final StringCOALESCE keyword.static final StringFOR UPDATE string.Fields inherited from class org.tentackle.sql.backends.AbstractBackend
TYPE_BIGINT, TYPE_BIT, TYPE_BLOB, TYPE_BOOL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTEA, TYPE_CHAR_1, TYPE_CLOB, TYPE_DATE, TYPE_DATETIME, TYPE_DATETIME_YEAR_TO_SECOND, TYPE_DECIMAL, TYPE_DECIMAL_19, TYPE_DOUBLE, TYPE_DOUBLE_PRECISION, TYPE_FLOAT, TYPE_FLOAT4, TYPE_FLOAT8, TYPE_INT, TYPE_INT2, TYPE_INT4, TYPE_INT8, TYPE_INTEGER, TYPE_NCHAR_1, TYPE_NUMBER, TYPE_NUMBER_1, TYPE_NUMBER_10, TYPE_NUMBER_19, TYPE_NUMBER_5, TYPE_NVARCHAR, TYPE_NVARCHAR_MAX, TYPE_REAL, TYPE_SMALLFLOAT, TYPE_SMALLINT, TYPE_TEXT, TYPE_TIME, TYPE_TIMESTAMP, TYPE_TINYINT, TYPE_UUID, TYPE_VARBINARY_MAX, TYPE_VARCHARFields inherited from interface org.tentackle.sql.Backend
SQL_ALLSTAR, SQL_ALTER_COLUMN, SQL_ALTER_INDEX, SQL_ALTER_TABLE, SQL_AND, SQL_ANDNOT, SQL_ARRAY_ALL, SQL_ARRAY_ALL_PAR, SQL_ARRAY_ANY, SQL_ARRAY_ANY_PAR, SQL_ARRAY_IN, SQL_ARRAY_IN_PAR, SQL_ARRAY_NOT_IN, SQL_ARRAY_NOT_IN_PAR, SQL_ARRAY_PAR, SQL_COMMA, SQL_COMMA_PAR, SQL_DELETE, SQL_DOT_STAR, 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildSelectSql(StringBuilder sqlBuilder, boolean writeLock, int limit, int offset) Creates a select statement string from an inner sql string.Gets the keyword for the COALESCE function.Gets the list of reserved words for this backend.protected booleanisLeadingSelectMissing(StringBuilder sqlBuilder) Determines whetherbuildSelectSql(StringBuilder, boolean, int, int)must prepend a"SELECT ".booleanTrue if backend provides locking-free sequences.
Sequences must not take part in transactions, i.e.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.sqlCreateForeignKey(String referencingTableName, String referencingColumnName, String referencedTableName, String referencedColumnName, String foreignKeyName, boolean composite) Generates the ALTER TABLE statement to add a foreign key constraint.sqlCreateSequence(String name, Long start, Long increment) Creates the SQL string to create a sequence.sqlCreateSequenceComment(String name, String comment) Creates the SQL string to comment a sequence.sqlDropForeignKey(String referencingTableName, String foreignKeyName) Generates the sql statement to drop a foreign key constraint.sqlNextFromSequence(String name) Creates the SQL string to retrieve the next id from a sequence.Methods inherited from class org.tentackle.sql.backends.AbstractBackend
assertValidName, buildSelectSql, columnTypeNullDefaultToString, columnTypeToString, createColumnMetaData, createConnection, createIndexColumnMetaData, createIndexMetaData, createPassword, createScriptRunner, createTableMetaData, extractWhereClause, getBlockCommentBegin, getBlockCommentBegins, getBlockCommentEnd, getBlockCommentEnds, getDefaultSchema, getDefaultSize, getEmptyString, getMaxScale, getMaxSize, getMetaData, getMigrationStrategy, getModelMetaData, getSingleLineComment, getSingleLineComments, getStatementSeparator, getStatementSeparators, getTableHeaders, getTableMetaData, isAliasRequiredForSubSelect, isArrayOperatorSupported, isClobSupported, isCommunicationLinkException, isConstraintException, isDatabaseInMemory, isDefaultEqual, isDeprecated, isDropIfExistsEnabled, isDropIfExistsSupported, isExceptionErrorCodeMatching, isExceptionStateMatching, isExceptionStateStartingWith, isExpressionReferringToTableBeingUpdatedSupported, isExtraCommitRequired, isFilteredIndexSupported, isFunctionBasedIndexSupported, isMatchingName, isPosixEscapeSyntaxSupported, isReleaseSavepointSupported, isReservedSchemaName, isReservedTableName, isReservedWord, isSchemaSupported, isTemporaryName, isTransientTransactionException, isTxRequiredForFetchsize, isUUIDSupported, jdbcTypeToSqlType, normalizeDefault, optimizeSql, setArray, setDropIfExistsEnabled, sqlAddColumn, sqlAlterColumnComment, sqlAlterColumnDefault, sqlAlterColumnNullConstraint, sqlAlterColumnType, sqlAlterTableComment, sqlAsBeforeTableAlias, sqlComment, sqlCreateColumn, sqlCreateColumnComment, sqlCreateIndex, sqlCreateSchema, sqlCreateTableAttributeWithoutComment, sqlCreateTableClosing, sqlCreateTableComment, sqlCreateTableIntro, sqlCreateTableIntroWithoutComment, sqlDropColumn, sqlDropIndex, sqlDropTable, sqlFunction, sqlJoin, sqlJoinSelects, sqlJoinSelects, sqlRenameAndAlterColumnType, sqlRenameColumn, sqlRenameIndex, sqlRenameTable, sqlTypeToString, sqlUpdateToNotNull, toInternalType, toQuotedString, toString, validateVersion, valueToLiteralMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tentackle.sql.Backend
getBackendId, getDriverClassName, getName, isMatchingUrl
-
Field Details
-
SQL_FOR_UPDATE
FOR UPDATE string.- See Also:
-
SQL_COALESCE
COALESCE keyword.- See Also:
-
RESERVED_WORDS_SQL92
array of reserved words.
-
-
Constructor Details
-
AbstractSql92Backend
public AbstractSql92Backend()Parent constructor.
-
-
Method Details
-
getReservedWords
Description copied from interface:BackendGets the list of reserved words for this backend.- Returns:
- the set of reserved words
-
buildSelectSql
Description copied from interface:BackendCreates a select statement string from an inner sql string.sqlBuilderis anything as[SELECT] FROM... WHERE... ORDER BY....
It is decorated with a leadingSELECT, if missing, plus 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
-
isLeadingSelectMissing
Determines whetherbuildSelectSql(StringBuilder, boolean, int, int)must prepend a"SELECT ".- Parameters:
sqlBuilder- the sql builder- Returns:
- true if leading select keyword is missing
-
setLeadingSelectParameters
Description copied from interface:BackendSets 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
public int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset) Description copied from interface:BackendSets 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
-
getCoalesceKeyword
Description copied from interface:BackendGets the keyword for the COALESCE function.- Specified by:
getCoalesceKeywordin interfaceBackend- Overrides:
getCoalesceKeywordin classAbstractBackend- Returns:
- the keyword
-
sqlCreateForeignKey
public String sqlCreateForeignKey(String referencingTableName, String referencingColumnName, String referencedTableName, String referencedColumnName, String foreignKeyName, boolean composite) Description copied from interface:BackendGenerates 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
Description copied from interface:BackendGenerates 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
-
isSequenceSupported
public boolean isSequenceSupported()Description copied from interface:BackendTrue if backend provides locking-free sequences.
Sequences must not take part in transactions, i.e. no read- or write-locks!- Returns:
- true if database supports sequences
-
sqlCreateSequence
Description copied from interface:BackendCreates the SQL string to create a sequence.- Parameters:
name- the sequence namestart- the optional start value, defaults to 1increment- the optional increment, defaults to 1- Returns:
- the SQL code
-
sqlCreateSequenceComment
Description copied from interface:BackendCreates the SQL string to comment a sequence.- Parameters:
name- the sequence namecomment- the comment- Returns:
- the SQL code
-
sqlNextFromSequence
Description copied from interface:BackendCreates the SQL string to retrieve the next id from a sequence.- Parameters:
name- the name of the sequence- Returns:
- the SQL code
-