- All Known Implementing Classes:
DefaultSqlDialect
public interface SqlDialect
Represents a specific SQL dialect with methods to determine feature support and handle identifier escaping.
- Since:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the limit should be applied after the SELECT clause,falseto apply the limit at the end of the query.booleanReturnstrueif the lock hint should be applied after the FROM clause,falseto apply the lock hint at the end of the query.Escapes the given database identifier (e.g., table or column name) according to this SQL dialect.Returns the lock hint for a shared reading lock.Returns the lock hint for a write lock.Returns the pattern for identifiers.Returns the pattern for multi line comments.Returns the pattern for string literals.default StringgetSafeIdentifier(String name) Returns a safe identifier for the given name, possibly escaping it if it is a keyword or contains invalid characters.Returns the pattern for single line comments.Returns the pattern for valid identifiers.booleanIndicates whether the given name is a keyword in this SQL dialect.limit(int limit) Returns a string template for the given limit.limit(int offset, int limit) Returns a string template for the given limit and offset.Returns a string for the given column name.name()Returns the name of the SQL dialect.offset(int offset) Returns a string template for the given offset.booleanIndicates whether the SQL dialect supports delete aliases.booleanIndicates whether the SQL dialect supports multi-value tuples in the IN clause.
-
Method Details
-
name
String name()Returns the name of the SQL dialect.- Returns:
- the name of the SQL dialect.
- Since:
- 1.2
-
supportsDeleteAlias
boolean supportsDeleteAlias()Indicates whether the SQL dialect supports delete aliases.Delete aliases allow delete statements to use table aliases in joins, making it easier to filter rows based on related data.
- Returns:
trueif delete aliases are supported,falseotherwise.
-
supportsMultiValueTuples
boolean supportsMultiValueTuples()Indicates whether the SQL dialect supports multi-value tuples in the IN clause.- Returns:
trueif multi-value tuples are supported,falseotherwise.- Since:
- 1.2
-
getValidIdentifierPattern
Pattern getValidIdentifierPattern()Returns the pattern for valid identifiers.- Returns:
- the pattern for valid identifiers.
- Since:
- 1.2
-
isKeyword
Indicates whether the given name is a keyword in this SQL dialect.- Parameters:
name- the name to check.- Returns:
trueif the name is a keyword,falseotherwise.- Since:
- 1.2
-
escape
Escapes the given database identifier (e.g., table or column name) according to this SQL dialect.- Parameters:
name- the identifier to escape (must not benull)- Returns:
- the escaped identifier
-
getSafeIdentifier
Returns a safe identifier for the given name, possibly escaping it if it is a keyword or contains invalid characters.- Parameters:
name- the name to check.- Returns:
- a safe identifier for the given name.
- Since:
- 1.2
-
getSingleLineCommentPattern
Pattern getSingleLineCommentPattern()Returns the pattern for single line comments.- Returns:
- the pattern for single line comments.
- Since:
- 1.2
-
getMultiLineCommentPattern
Pattern getMultiLineCommentPattern()Returns the pattern for multi line comments.- Returns:
- the pattern for multi line comments.
- Since:
- 1.2
-
getIdentifierPattern
Pattern getIdentifierPattern()Returns the pattern for identifiers.- Returns:
- the pattern for identifiers.
- Since:
- 1.2
-
getQuoteLiteralPattern
Pattern getQuoteLiteralPattern()Returns the pattern for string literals.- Returns:
- the pattern for string literals.
- Since:
- 1.2
-
multiValueIn
String multiValueIn(@Nonnull List<Map<String, Object>> values, @Nonnull Consumer<Object> parameterConsumer) throws SqlTemplateExceptionReturns a string for the given column name.- Parameters:
values- the (multi) values to use in the IN clause.parameterConsumer- the consumer for the parameters.- Returns:
- the string that represents the multi value IN clause.
- Throws:
SqlTemplateException- if the values are incompatible.- Since:
- 1.2
-
applyLimitAfterSelect
boolean applyLimitAfterSelect()Returnstrueif the limit should be applied after the SELECT clause,falseto apply the limit at the end of the query.- Returns:
trueif the limit should be applied after the SELECT clause,falseto apply the limit at the end of the query.- Since:
- 1.2
-
limit
Returns a string template for the given limit.- Parameters:
limit- the maximum number of records to return.- Returns:
- a string template for the given limit.
- Since:
- 1.2
-
offset
Returns a string template for the given offset.- Parameters:
offset- the offset.- Returns:
- a string template for the given offset.
- Since:
- 1.2
-
limit
Returns a string template for the given limit and offset.- Parameters:
offset- the offset.limit- the maximum number of records to return.- Returns:
- a string template for the given limit and offset.
- Since:
- 1.2
-
applyLockHintAfterFrom
boolean applyLockHintAfterFrom()Returnstrueif the lock hint should be applied after the FROM clause,falseto apply the lock hint at the end of the query.- Returns:
trueif the lock hint should be applied after the FROM clause,falseto apply the lock hint at the end of the query.- Since:
- 1.2
-
forUpdateLockHint
String forUpdateLockHint()Returns the lock hint for a write lock.- Returns:
- the lock hint for a write lock.
- Since:
- 1.2
-