Package com.blazebit.persistence.spi
Interface DbmsDialect
public interface DbmsDialect
Interface for implementing some dbms specifics.
- Since:
- 1.1.0
- Author:
- Christian Beikov, Moritz Becker
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionappendExtendedSql
(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates) Deprecated.appendExtendedSql
(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String dmlAffectedTable, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates) Appends the with clause to the sql string builder.void
appendOrderByElement
(StringBuilder sqlSb, OrderByElement orderByElement, String[] aliases) Appends the order by element to the SQL builder.void
appendSet
(StringBuilder sqlSb, SetOperationType setType, boolean isSubquery, List<String> operands, List<? extends OrderByElement> orderByElements, String limit, String offset) Connects the given operands with the given set operation and appends that to the sql string builder.Returns the cast expression for the given expression to the given sql type.Creates a new limit handler for an SQL query.Extracts the result set for the columns that are returned from a DML statement.Returns default escape character of the like predicate.Returns the delete join style that is supported by the dbms.Returns the name of a dummy table like DUAL in Oracle or null if none is required.Returns the lateral style that is supported by the dbms.Returns the name of the physical row id if the DBMS has such a concept, otherwise null.int
Returns the flags to pass toConnection.prepareStatement(String, int)
for configuring that column values are returned.getSqlType
(Class<?> castType) Returns the sql type for the java class type for usage in cast expressions.Returns the update join style that is supported by the dbms.Returns the strategy to use for values generation.getWithClause
(boolean recursive) Returns the SQL representation for the normal or recursive with clause.boolean
Returns true if the dbms treats null as the smallest value, false is highest.boolean
Returns whether parameters need to be casted if occurring in an untyped context like e.g.boolean
Returns whether sql types for the returning columns need to be provided.boolean
Returns whether select items need to have unique names even though table column aliasing is used i.e.prepare
(PreparedStatement ps, int[] returningSqlTypes) Configures the prepared statement with the return types of the columns to be returned.boolean
Returns true if the dbms requires a null literal to be casted.boolean
Returns true if the dbms supports the ANSI row value constructor syntax, false otherwise.boolean
Returns true if the multiset implementation for the dbms supports exists and supports arbitrary length.boolean
Returns true if the dbms supports boolean aggregation through EVERY / SOME / ANY / BOOL_AND / BOOL_OR.boolean
Returns true if the dbms supports complex expressions like subqueries in the join on clause, false otherwise.boolean
Returns true if the dbms supports tuples in the count function, false otherwise.boolean
supportsExcept
(boolean all) Returns true if the dbms supports the set operation EXCEPT, false otherwise.boolean
Returns true if the dbms supports the FILTER clause on aggregate functions.boolean
Returns true if the dbms supports all <, <=, >, >=, =, <> comparison operations for row values.boolean
Returns true if the dbms supports matching non-trivial expressions that appear in the group by clause with usages in the having clause.boolean
supportsIntersect
(boolean all) Returns true if the dbms supports the set operation INTERSECT, false otherwise.boolean
Returns true if the dbms supports joins in the recursive part of a CTE, false otherwise.boolean
Returns true if the dbms supports limit for a subquery in a quantified predicate, false otherwise.boolean
Returns true if the dbms supports a limit without an order by clause, false otherwise.boolean
Returns true if the dbms supports modification queries in the with clause, false otherwise.boolean
Returns true if the dbms supports nested correlations, false otherwise.boolean
Returns true if the dbms supports the non-recursive with clause, false otherwise.boolean
Returns true if the dbms supports null precedence for ORDER BY clause.boolean
Returns true if the dbms supports returning all generated keys, false otherwise.boolean
Returns true if the dbms supports returning columns from a modified row, false otherwise.boolean
Returns true if the dbms supports returning generated keys, false otherwise.boolean
Returns true if the dbms supports row value constructor syntax, false otherwise.boolean
supportsUnion
(boolean all) Returns true if the dbms supports the set operation UNION, false otherwise.boolean
Returns true if the dbms supports window functions.boolean
Returns true if the dbms supports null precedence for order clauses in the WINDOW clause.boolean
Returns true if the dbms supports the with clause, false otherwise.boolean
Returns true if the dbms supports the with clause head for aliasing, false otherwise.boolean
Returns true if the dbms supports the with clause in modification queries, false otherwise.boolean
Returns true if the dbms wants to use the JDBC executeUpdate method when using the with clause in modification queries, false otherwise.
-
Method Details
-
supportsWithClause
boolean supportsWithClause()Returns true if the dbms supports the with clause, false otherwise.- Returns:
- Whether the with clause is supported by the dbms
-
supportsNonRecursiveWithClause
boolean supportsNonRecursiveWithClause()Returns true if the dbms supports the non-recursive with clause, false otherwise.- Returns:
- Whether the non-recursive with clause is supported by the dbms
-
supportsWithClauseHead
boolean supportsWithClauseHead()Returns true if the dbms supports the with clause head for aliasing, false otherwise.- Returns:
- Whether the with clause head is supported by the dbms
-
getWithClause
Returns the SQL representation for the normal or recursive with clause.- Parameters:
recursive
- Whether the clause should be able to contain recursive queries or not- Returns:
- The with clause name
-
appendExtendedSql
Map<String,String> appendExtendedSql(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates) Deprecated.Appends the with clause to the sql string builder.- Parameters:
sqlSb
- The sql string builder to which the with clause should be append tostatementType
- The type of the statement in the sql string builderisSubquery
- True if the query in the sql string builder is a subquery, false otherwiseisEmbedded
- True if the query in the sql string builder will be embedded in a clause, false otherwisewithClause
- The with clause which should be appended, or null if nonelimit
- The limit for the limit clause, or null if no limitoffset
- The offset for the offset clause, or null if no offsetreturningColumns
- The columns which the sql should return or null if noneincludedModificationStates
- The modification states of the returned columns for which additional CTEs should be generated mapped to the expected CTE names- Returns:
- Generated CTEs queries for the requested modification states
- See Also:
-
appendExtendedSql
Map<String,String> appendExtendedSql(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, String dmlAffectedTable, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates) Appends the with clause to the sql string builder.- Parameters:
sqlSb
- The sql string builder to which the with clause should be append tostatementType
- The type of the statement in the sql string builderisSubquery
- True if the query in the sql string builder is a subquery, false otherwiseisEmbedded
- True if the query in the sql string builder will be embedded in a clause, false otherwisewithClause
- The with clause which should be appended, or null if nonelimit
- The limit for the limit clause, or null if no limitoffset
- The offset for the offset clause, or null if no offsetdmlAffectedTable
- The table that is affected by a DML statement if this is a DML statement or nullreturningColumns
- The columns which the sql should return or null if noneincludedModificationStates
- The modification states of the returned columns for which additional CTEs should be generated mapped to the expected CTE names- Returns:
- Generated CTEs queries for the requested modification states
- Since:
- 1.5.0
-
appendSet
void appendSet(StringBuilder sqlSb, SetOperationType setType, boolean isSubquery, List<String> operands, List<? extends OrderByElement> orderByElements, String limit, String offset) Connects the given operands with the given set operation and appends that to the sql string builder.- Parameters:
sqlSb
- The sql string builder to which the connected operands should be appended tosetType
- The type of the set connectionisSubquery
- True if the query in the sql string builder is a subquery, false otherwiseoperands
- An list of operand sql stringsorderByElements
- The order by elements of the composite set operationlimit
- The limit for the limit clause, or null if no limitoffset
- The offset for the offset clause, or null if no offset
-
appendOrderByElement
Appends the order by element to the SQL builder.- Parameters:
sqlSb
- The string builderorderByElement
- The order by elementaliases
- The aliases, may benull
- Since:
- 1.4.1
-
createLimitHandler
DbmsLimitHandler createLimitHandler()Creates a new limit handler for an SQL query.- Returns:
- A new limit handler for a query
- Since:
- 1.2.0
-
supportsLimitWithoutOrderBy
boolean supportsLimitWithoutOrderBy()Returns true if the dbms supports a limit without an order by clause, false otherwise.- Returns:
- Whether a limit without an order by clause is supported by the dbms
- Since:
- 1.5.0
-
supportsLimitInQuantifiedPredicateSubquery
boolean supportsLimitInQuantifiedPredicateSubquery()Returns true if the dbms supports limit for a subquery in a quantified predicate, false otherwise.- Returns:
- Whether limit for a subquery in a quantified predicate is supported by the dbms
- Since:
- 1.5.0
-
supportsNestedCorrelations
boolean supportsNestedCorrelations()Returns true if the dbms supports nested correlations, false otherwise.- Returns:
- Whether nested correlations are supported by the dbms
- Since:
- 1.5.0
-
supportsWithClauseInModificationQuery
boolean supportsWithClauseInModificationQuery()Returns true if the dbms supports the with clause in modification queries, false otherwise.- Returns:
- Whether the with clause is supported in modification queries by the dbms
-
supportsModificationQueryInWithClause
boolean supportsModificationQueryInWithClause()Returns true if the dbms supports modification queries in the with clause, false otherwise.- Returns:
- Whether modification queries are supported in the with clause by the dbms
-
usesExecuteUpdateWhenWithClauseInModificationQuery
boolean usesExecuteUpdateWhenWithClauseInModificationQuery()Returns true if the dbms wants to use the JDBC executeUpdate method when using the with clause in modification queries, false otherwise.- Returns:
- Whether the JDBC executeUpdate method should be used when using the with clause is in modification queries
-
supportsReturningGeneratedKeys
boolean supportsReturningGeneratedKeys()Returns true if the dbms supports returning generated keys, false otherwise.- Returns:
- Whether returning generated keys is supported by the dbms
-
supportsReturningAllGeneratedKeys
boolean supportsReturningAllGeneratedKeys()Returns true if the dbms supports returning all generated keys, false otherwise.- Returns:
- Whether returning all generated keys is supported by the dbms
-
supportsReturningColumns
boolean supportsReturningColumns()Returns true if the dbms supports returning columns from a modified row, false otherwise.- Returns:
- Whether returning columns from a modified row is supported by the dbms
-
supportsGroupByExpressionInHavingMatching
boolean supportsGroupByExpressionInHavingMatching()Returns true if the dbms supports matching non-trivial expressions that appear in the group by clause with usages in the having clause.- Returns:
- Whether expressions from the group by clause are matched and reused in the having clause by the dbms
- Since:
- 1.2.0
-
supportsComplexJoinOn
boolean supportsComplexJoinOn()Returns true if the dbms supports complex expressions like subqueries in the join on clause, false otherwise.- Returns:
- Whether complex join on clauses are supported by the dbms
- Since:
- 1.2.0
-
supportsUnion
boolean supportsUnion(boolean all) Returns true if the dbms supports the set operation UNION, false otherwise.- Parameters:
all
- True if the non-distinct ALL operation should be checked, false otherwise.- Returns:
- Whether UNION is supported by the dbms
- Since:
- 1.1.0
-
supportsIntersect
boolean supportsIntersect(boolean all) Returns true if the dbms supports the set operation INTERSECT, false otherwise.- Parameters:
all
- True if the non-distinct ALL operation should be checked, false otherwise.- Returns:
- Whether INTERSECT is supported by the dbms
- Since:
- 1.1.0
-
supportsExcept
boolean supportsExcept(boolean all) Returns true if the dbms supports the set operation EXCEPT, false otherwise.- Parameters:
all
- True if the non-distinct ALL operation should be checked, false otherwise.- Returns:
- Whether EXCEPT is supported by the dbms
- Since:
- 1.1.0
-
supportsJoinsInRecursiveCte
boolean supportsJoinsInRecursiveCte()Returns true if the dbms supports joins in the recursive part of a CTE, false otherwise.- Returns:
- Whether joins are supported in recursive CTEs by the dbms
- Since:
- 1.2.0
-
supportsAnsiRowValueConstructor
boolean supportsAnsiRowValueConstructor()Returns true if the dbms supports the ANSI row value constructor syntax, false otherwise.- Returns:
- Whether ANSI row value constructor syntax is supported by the dbms
- Since:
- 1.5.0
-
supportsRowValueConstructor
boolean supportsRowValueConstructor()Returns true if the dbms supports row value constructor syntax, false otherwise.- Returns:
- Whether row value constructor syntax is supported by the dbms
- Since:
- 1.2.0
-
supportsFullRowValueComparison
boolean supportsFullRowValueComparison()Returns true if the dbms supports all <, <=, >, >=, =, <> comparison operations for row values. Note that some DBMS only support = and <> operators.- Returns:
- Whether full row value comparison operations are supported by the dbms
- Since:
- 1.2.0
-
supportsCountTuple
boolean supportsCountTuple()Returns true if the dbms supports tuples in the count function, false otherwise.- Returns:
- Whether tuples in the count function are supported by the dbms
- Since:
- 1.6.0
-
supportsWindowFunctions
boolean supportsWindowFunctions()Returns true if the dbms supports window functions.- Returns:
- Whether the dbms supports window functions
- Since:
- 1.4.0
-
supportsFilterClause
boolean supportsFilterClause()Returns true if the dbms supports the FILTER clause on aggregate functions.- Returns:
- Whether the dbms supports the FILTER clause on aggregate functions
- Since:
- 1.4.0
-
supportsNullPrecedence
boolean supportsNullPrecedence()Returns true if the dbms supports null precedence for ORDER BY clause.- Returns:
- whether the dbms supports null precedence for ORDER BY clause
- Since:
- 1.4.0
-
supportsWindowNullPrecedence
boolean supportsWindowNullPrecedence()Returns true if the dbms supports null precedence for order clauses in the WINDOW clause.- Returns:
- whether the dbms supports null precedence for order clauses in the WINDOW clause
- Since:
- 1.4.0
-
supportsBooleanAggregation
boolean supportsBooleanAggregation()Returns true if the dbms supports boolean aggregation through EVERY / SOME / ANY / BOOL_AND / BOOL_OR.- Returns:
- whether the dbms supports boolean aggregation through EVERY / SOME / ANY / BOOL_AND / BOOL_OR
- Since:
- 1.4.0
-
isNullSmallest
boolean isNullSmallest()Returns true if the dbms treats null as the smallest value, false is highest.- Returns:
- whether the dbms treats null as the smallest value, false if highest
- Since:
- 1.4.0
-
requiresNullCast
boolean requiresNullCast()Returns true if the dbms requires a null literal to be casted.- Returns:
- whether the dbms requires a null literal to be casted
- Since:
- 1.4.1
-
getLateralStyle
LateralStyle getLateralStyle()Returns the lateral style that is supported by the dbms.- Returns:
- the lateral style that is supported by the dbms
- Since:
- 1.4.1
-
getPhysicalRowId
String getPhysicalRowId()Returns the name of the physical row id if the DBMS has such a concept, otherwise null.- Returns:
- the name of the physical row id if the DBMS has such a concept, otherwise null
- Since:
- 1.5.0
-
getDeleteJoinStyle
DeleteJoinStyle getDeleteJoinStyle()Returns the delete join style that is supported by the dbms.- Returns:
- the delete join style that is supported by the dbms
- Since:
- 1.5.0
-
getUpdateJoinStyle
UpdateJoinStyle getUpdateJoinStyle()Returns the update join style that is supported by the dbms.- Returns:
- the update join style that is supported by the dbms
- Since:
- 1.5.0
-
supportsArbitraryLengthMultiset
boolean supportsArbitraryLengthMultiset()Returns true if the multiset implementation for the dbms supports exists and supports arbitrary length.- Returns:
- whether the multiset implementation for the dbms supports exists and supports arbitrary length
- Since:
- 1.5.0
-
getSqlType
Returns the sql type for the java class type for usage in cast expressions.- Parameters:
castType
- The java class type- Returns:
- The sql type
- Since:
- 1.2.0
-
getValuesStrategy
ValuesStrategy getValuesStrategy()Returns the strategy to use for values generation.- Returns:
- The VALUES strategy
- Since:
- 1.2.0
-
needsUniqueSelectItemNamesAlsoWhenTableColumnAliasing
boolean needsUniqueSelectItemNamesAlsoWhenTableColumnAliasing()Returns whether select items need to have unique names even though table column aliasing is used i.e. `from (select ...) t(c1,c2)`.- Returns:
- True if aliasing is required, otherwise false
- Since:
- 1.6.7
-
needsCastParameters
boolean needsCastParameters()Returns whether parameters need to be casted if occurring in an untyped context like e.g. VALUES clause.- Returns:
- True if casting is required, otherwise false
- Since:
- 1.2.0
-
getDummyTable
String getDummyTable()Returns the name of a dummy table like DUAL in Oracle or null if none is required.- Returns:
- The dummy table name or null
- Since:
- 1.2.0
-
cast
Returns the cast expression for the given expression to the given sql type.- Parameters:
expression
- The expression to castsqlType
- The type to which to cast- Returns:
- The cast expression
- Since:
- 1.2.0
-
getDefaultEscapeCharacter
Character getDefaultEscapeCharacter()Returns default escape character of the like predicate.- Returns:
- The default escape character of the like predicate
- Since:
- 1.6.3
-
needsReturningSqlTypes
boolean needsReturningSqlTypes()Returns whether sql types for the returning columns need to be provided.- Returns:
- True if sql types are required, otherwise false
- Since:
- 1.2.0
-
getPrepareFlags
int getPrepareFlags()Returns the flags to pass toConnection.prepareStatement(String, int)
for configuring that column values are returned.- Returns:
- The prepare flags
- Since:
- 1.2.0
-
prepare
Configures the prepared statement with the return types of the columns to be returned.- Parameters:
ps
- The prepared statement to preparereturningSqlTypes
- The SQL types of the column values that should be returned- Returns:
- The prepared statement
- Throws:
SQLException
- When preparing the statement fails- Since:
- 1.2.0
-
extractReturningResult
Extracts the result set for the columns that are returned from a DML statement.- Parameters:
ps
- The prepared statement- Returns:
- The result set for the returning clause
- Throws:
SQLException
- When extracting from the statement fails- Since:
- 1.2.0
-
appendExtendedSql(StringBuilder, DbmsStatementType, boolean, boolean, StringBuilder, String, String, String, String[], Map)
instead