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:
CriteriaBuilderConfiguration.registerDialect(java.lang.String, com.blazebit.persistence.spi.DbmsDialect)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,String>
appendExtendedSql(StringBuilder sqlSb, DbmsStatementType statementType, boolean isSubquery, boolean isEmbedded, StringBuilder withClause, String limit, String offset, 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.String
cast(String expression, String sqlType)
Returns the cast expression for the given expression to the given sql type.DbmsLimitHandler
createLimitHandler()
Creates a new limit handler for an SQL query.ResultSet
extractReturningResult(PreparedStatement ps)
TODO: documentation.String
getDummyTable()
Returns the name of a dummy table like DUAL in Oracle or null if none is required.LateralStyle
getLateralStyle()
Returns the lateral style that is supported by the dbms.int
getPrepareFlags()
TODO: documentation.String
getSqlType(Class<?> castType)
Returns the sql type for the java class type for usage in cast expressions.ValuesStrategy
getValuesStrategy()
Returns the strategy to use for values generation.String
getWithClause(boolean recursive)
Returns the SQL representation for the normal or recursive with clause.boolean
isNullSmallest()
Returns true if the dbms treats null as the smallest value, false is highest.boolean
needsCastParameters()
Returns whether parameters need to be casted if occurring in an untyped context like e.g.boolean
needsReturningSqlTypes()
Returns whether sql types for the returning columns need to be provided.PreparedStatement
prepare(PreparedStatement ps, int[] returningSqlTypes)
TODO: documentation.boolean
requiresNullCast()
Returns true if the dbms requires a null literal to be casted.boolean
supportsAnsiRowValueConstructor()
Returns true if the dbms supports the ANSI row value constructor syntax, false otherwise.boolean
supportsArbitraryLengthMultiset()
Returns true if the multiset implementation for the dbms supports exists and supports arbitrary length.boolean
supportsBooleanAggregation()
Returns true if the dbms supports boolean aggregation through EVERY / SOME / ANY / BOOL_AND / BOOL_OR.boolean
supportsComplexJoinOn()
Returns true if the dbms supports complex expressions like subqueries in the join on clause, false otherwise.boolean
supportsExcept(boolean all)
Returns true if the dbms supports the set operation EXCEPT, false otherwise.boolean
supportsFilterClause()
Returns true if the dbms supports the FILTER clause on aggregate functions.boolean
supportsFullRowValueComparison()
Returns true if the dbms supports all <, <=, >, >=, =, <> comparison operations for row values.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.boolean
supportsIntersect(boolean all)
Returns true if the dbms supports the set operation INTERSECT, false otherwise.boolean
supportsJoinsInRecursiveCte()
Returns true if the dbms supports joins in the recursive part of a CTE, false otherwise.boolean
supportsLimitInQuantifiedPredicateSubquery()
Returns true if the dbms supports limit for a subquery in a quantified predicate, false otherwise.boolean
supportsLimitWithoutOrderBy()
Returns true if the dbms supports a limit without an order by clause, false otherwise.boolean
supportsModificationQueryInWithClause()
Returns true if the dbms supports modification queries in the with clause, false otherwise.boolean
supportsNestedCorrelations()
Returns true if the dbms supports nested correlations, false otherwise.boolean
supportsNonRecursiveWithClause()
Returns true if the dbms supports the non-recursive with clause, false otherwise.boolean
supportsNullPrecedence()
Returns true if the dbms supports null precedence for ORDER BY clause.boolean
supportsReturningAllGeneratedKeys()
Returns true if the dbms supports returning all generated keys, false otherwise.boolean
supportsReturningColumns()
Returns true if the dbms supports returning columns from a modified row, false otherwise.boolean
supportsReturningGeneratedKeys()
Returns true if the dbms supports returning generated keys, false otherwise.boolean
supportsRowValueConstructor()
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
supportsWindowFunctions()
Returns true if the dbms supports window functions.boolean
supportsWindowNullPrecedence()
Returns true if the dbms supports null precedence for order clauses in the WINDOW clause.boolean
supportsWithClause()
Returns true if the dbms supports the with clause, false otherwise.boolean
supportsWithClauseHead()
Returns true if the dbms supports the with clause head for aliasing, false otherwise.boolean
supportsWithClauseInModificationQuery()
Returns true if the dbms supports the with clause in modification queries, false otherwise.boolean
usesExecuteUpdateWhenWithClauseInModificationQuery()
Returns true if the dbms wants to use the JDBC executeUpdate method when using the with clause in modification queries, false otherwise.
-
-
-
Method Detail
-
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
String getWithClause(boolean recursive)
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)
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
-
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
void appendOrderByElement(StringBuilder sqlSb, OrderByElement orderByElement, String[] aliases)
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
-
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
-
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
String getSqlType(Class<?> castType)
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
-
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
String cast(String expression, String sqlType)
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
-
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()
TODO: documentation.- Returns:
- The prepare flags
- Since:
- 1.2.0
-
prepare
PreparedStatement prepare(PreparedStatement ps, int[] returningSqlTypes) throws SQLException
TODO: documentation.- Parameters:
ps
- TODO: documentationreturningSqlTypes
- TODO: documentation- Returns:
- The prepared statement
- Throws:
SQLException
- When preparing the statement fails- Since:
- 1.2.0
-
extractReturningResult
ResultSet extractReturningResult(PreparedStatement ps) throws SQLException
TODO: documentation.- Parameters:
ps
- TODO: documentation- Returns:
- The result set for the returning clause
- Throws:
SQLException
- When extracting from the statement fails- Since:
- 1.2.0
-
-