- All Implemented Interfaces:
Dialect
- Direct Known Subclasses:
Db2Dialect,H212126Dialect,HsqldbDialect,Mssql2008Dialect,MysqlDialect,Oracle11Dialect,PostgresDialect,SqliteDialect
Dialect.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classA standard implementation ofExpressionFunctions.static classstatic classA standard implementation ofScriptBlockContext.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final charthe quotation mark of the endprotected final ExpressionFunctionsthe aggregation of expression functionsprotected final JdbcMappingVisitorprotected static final charthe quotation mark of the startprotected final SqlLogFormattingVisitorthe visitor that mapsWrappertoSqlLogFormatterthe set of SQLState code that represents unique violation -
Constructor Summary
ConstructorsConstructorDescriptionStandardDialect(ExpressionFunctions expressionFunctions) StandardDialect(JdbcMappingVisitor jdbcMappingVisitor) StandardDialect(JdbcMappingVisitor jdbcMappingVisitor, SqlLogFormattingVisitor sqlLogFormattingVisitor) StandardDialect(JdbcMappingVisitor jdbcMappingVisitor, SqlLogFormattingVisitor sqlLogFormattingVisitor, ExpressionFunctions expressionFunctions) StandardDialect(SqlLogFormattingVisitor sqlLogFormattingVisitor) -
Method Summary
Modifier and TypeMethodDescriptionapplyQuote(String name) Encloses the name with quotation marks.Creates the context object to process an SQL block in a script.Returns the type of the auto generated keys.protected SQLExceptiongetCauseSQLException(SQLException sqlException) Returns the criteria builder for this dialect.<ENTITY> DeleteAssemblergetDeleteAssembler(DeleteAssemblerContext<ENTITY> context) Provides an implementation ofDeleteAssemblerbased on the given context.protected intgetErrorCode(SQLException sqlException) Returns the aggregation of the expression functions that are available in the SQL templates.Sql<?>getIdentityReservationSql(String catalogName, String schemaName, String tableName, String columnName, boolean isQuoteRequired, boolean isIdColumnQuoteRequired, int reservationSize) Returns an SQL object to reserve identity in the database.Sql<?>getIdentitySelectSql(String catalogName, String schemaName, String tableName, String columnName, boolean isQuoteRequired, boolean isIdColumnQuoteRequired) Returns an SQL object to retrieve IDENTITY values that were generated during an insert operation.<ENTITY> InsertAssemblergetInsertAssembler(InsertAssemblerContext<ENTITY> context) Provides an implementation ofInsertAssemblerbased on the given context.<ENTITY> MultiInsertAssemblergetMultiInsertAssembler(MultiInsertAssemblerContext<ENTITY> context) Provides an implementation ofMultiInsertAssemblerbased on the given context.getName()Returns the name of this dialect.getRootCause(SQLException sqlException) Returns the root cause of the SQL exception.Returns the delimiter that is used as the end of an SQL block in a script.getSequenceNextValSql(String qualifiedSequenceName, long allocationSize) Returns an SQL object to retrieve the next value from a database sequence.Returns the visitor that mapsWrappertoSqlLogFormatter.protected StringgetSQLState(SQLException sqlException) <ENTITY> UpdateAssemblergetUpdateAssembler(UpdateAssemblerContext<ENTITY> context) Provides an implementation ofUpdateAssemblerbased on the given context.getUpsertAssembler(UpsertAssemblerContext context) Returns the UpsertAssembler implementation for the given context.booleanDetermines whether this dialect includes IDENTITY columns in SQL INSERT statements.booleanisUniqueConstraintViolated(SQLException sqlException) Determines whether the given SQLException represents a unique constraint violation.removeQuote(String name) Removes quotation marks from the namebooleanDetermines whether this dialect supports retrieving auto-generated keys viaStatement.getGeneratedKeys().booleanDetermines whether this dialect supports reliable results fromStatement.executeBatch().booleanDetermines whether this dialect supports the IDENTITY column.booleanDetermines whether this dialect supports reserving identity values in advance.booleanDetermines whether this dialect supports result sets as OUT parameters in stored procedures.booleansupportsSelectForUpdate(SelectForUpdateType type, boolean withTargets) Determines whether this dialect supports pessimistic locking with the specified options.booleanDetermines whether this dialect supports database sequences.protected SqlNodetoCountCalculatingSqlNode(SqlNode sqlNode) protected SqlNodetoCountGettingSqlNode(SqlNode sqlNode) protected SqlNodetoForUpdateSqlNode(SqlNode sqlNode, SelectForUpdateType forUpdateType, int waitSeconds, String... aliases) protected SqlNodetoPagingSqlNode(SqlNode sqlNode, long offset, long limit) transformSelectSqlNode(SqlNode sqlNode, SelectOptions options) Transforms the SQL node for a SELECT statement according to the specified options.Transforms the SQL node to create a query that returns the total count of rows.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.seasar.doma.jdbc.dialect.Dialect
includesIdentityColumn, supportsAliasInDeleteClause, supportsAliasInDeleteStatement, supportsAliasInUpdateClause, supportsAliasInUpdateStatement, supportsAutoIncrementWhenInsertingMultipleRows, supportsBatchExecutionReturningGeneratedValues, supportsModOperator, supportsMultiRowInsertStatement, supportsParenthesesForSetOperands, supportsReturning, supportsUpsertEmulationWithMergeStatement
-
Field Details
-
OPEN_QUOTE
protected static final char OPEN_QUOTEthe quotation mark of the start- See Also:
-
CLOSE_QUOTE
protected static final char CLOSE_QUOTEthe quotation mark of the end- See Also:
-
UNIQUE_CONSTRAINT_VIOLATION_STATE_CODES
the set of SQLState code that represents unique violation -
jdbcMappingVisitor
-
sqlLogFormattingVisitor
the visitor that mapsWrappertoSqlLogFormatter -
expressionFunctions
the aggregation of expression functions
-
-
Constructor Details
-
StandardDialect
public StandardDialect() -
StandardDialect
-
StandardDialect
-
StandardDialect
-
StandardDialect
public StandardDialect(JdbcMappingVisitor jdbcMappingVisitor, SqlLogFormattingVisitor sqlLogFormattingVisitor) -
StandardDialect
public StandardDialect(JdbcMappingVisitor jdbcMappingVisitor, SqlLogFormattingVisitor sqlLogFormattingVisitor, ExpressionFunctions expressionFunctions)
-
-
Method Details
-
getName
Description copied from interface:DialectReturns the name of this dialect.The dialect name typically identifies the database system that this dialect supports. This name can be used for logging, debugging, or to make decisions based on the specific database being used.
Each dialect implementation should return a unique and descriptive name.
-
transformSelectSqlNode
Description copied from interface:DialectTransforms the SQL node for a SELECT statement according to the specified options.This method is responsible for applying database-specific transformations to SELECT statements, such as adding pagination (LIMIT/OFFSET), FOR UPDATE clauses, or other dialect-specific syntax.
- Specified by:
transformSelectSqlNodein interfaceDialect- Parameters:
sqlNode- the SQL node representing the SELECT statement to transformoptions- the options that specify how to transform the SQL, including pagination and locking settings- Returns:
- the transformed SQL node with dialect-specific modifications applied
-
toCountCalculatingSqlNode
-
toPagingSqlNode
-
toForUpdateSqlNode
protected SqlNode toForUpdateSqlNode(SqlNode sqlNode, SelectForUpdateType forUpdateType, int waitSeconds, String... aliases) -
transformSelectSqlNodeForGettingCount
Description copied from interface:DialectTransforms the SQL node to create a query that returns the total count of rows.This method is typically used for pagination scenarios where the total number of results needs to be known. It transforms a regular SELECT statement into a COUNT query that returns the total number of rows that would be returned by the original query without pagination.
The implementation should handle removing ORDER BY clauses and other elements that are not necessary for counting rows, while preserving the WHERE conditions and JOIN clauses.
- Specified by:
transformSelectSqlNodeForGettingCountin interfaceDialect- Parameters:
sqlNode- the SQL node representing the original SELECT statement- Returns:
- the transformed SQL node that will return the total row count
-
toCountGettingSqlNode
-
isUniqueConstraintViolated
Description copied from interface:DialectDetermines whether the given SQLException represents a unique constraint violation.Different database systems use different error codes and states to indicate unique constraint violations. This method abstracts these differences.
- Specified by:
isUniqueConstraintViolatedin interfaceDialect- Parameters:
sqlException- the SQL exception to analyze- Returns:
trueif the exception represents a unique constraint violation,falseotherwise
-
getSQLState
-
getErrorCode
-
getCauseSQLException
-
getRootCause
Description copied from interface:DialectReturns the root cause of the SQL exception.- Specified by:
getRootCausein interfaceDialect- Parameters:
sqlException- the SQL exception- Returns:
- the root cause
-
supportsAutoGeneratedKeys
public boolean supportsAutoGeneratedKeys()Description copied from interface:DialectDetermines whether this dialect supports retrieving auto-generated keys viaStatement.getGeneratedKeys().This feature allows retrieving values that were automatically generated during an insert operation, such as identity column values, without executing a separate query.
- Specified by:
supportsAutoGeneratedKeysin interfaceDialect- Returns:
trueif this dialect supports retrieving auto-generated keys,falseotherwise
-
supportsBatchUpdateResults
public boolean supportsBatchUpdateResults()Description copied from interface:DialectDetermines whether this dialect supports reliable results fromStatement.executeBatch().Some database systems do not correctly report the number of affected rows for each statement in a batch operation. This method indicates whether the dialect can rely on these results.
- Specified by:
supportsBatchUpdateResultsin interfaceDialect- Returns:
trueif this dialect supports reliable batch update results,falseotherwise
-
supportsIdentity
public boolean supportsIdentity()Description copied from interface:DialectDetermines whether this dialect supports the IDENTITY column.An IDENTITY column is a column that automatically generates a unique value for each row when data is inserted. The exact implementation varies by database system.
- Specified by:
supportsIdentityin interfaceDialect- Returns:
trueif this dialect supports IDENTITY columns,falseotherwise
-
supportsSequence
public boolean supportsSequence()Description copied from interface:DialectDetermines whether this dialect supports database sequences.A sequence is a database object that generates a sequence of unique numbers. Sequences are commonly used to generate primary key values.
- Specified by:
supportsSequencein interfaceDialect- Returns:
trueif this dialect supports sequences,falseotherwise
-
supportsIdentityReservation
public boolean supportsIdentityReservation()Description copied from interface:DialectDetermines whether this dialect supports reserving identity values in advance.Some database systems allow pre-allocating a range of identity values, which can improve performance in certain scenarios.
- Specified by:
supportsIdentityReservationin interfaceDialect- Returns:
trueif this dialect supports identity reservation,falseotherwise
-
includesIdentityColumn
public boolean includesIdentityColumn()Description copied from interface:DialectDetermines whether this dialect includes IDENTITY columns in SQL INSERT statements.Some database systems require that IDENTITY columns be excluded from INSERT statements, while others allow or require them to be included.
- Specified by:
includesIdentityColumnin interfaceDialect- Returns:
trueif this dialect includes IDENTITY columns in INSERT statements,falseotherwise
-
supportsSelectForUpdate
Description copied from interface:DialectDetermines whether this dialect supports pessimistic locking with the specified options.Pessimistic locking (SELECT FOR UPDATE) prevents other transactions from modifying selected rows. Different database systems support different variations of this feature.
- Specified by:
supportsSelectForUpdatein interfaceDialect- Parameters:
type- the type of pessimistic locking (e.g., standard FOR UPDATE, NOWAIT, WAIT)withTargets-trueif specific columns are targeted for locking,falsefor row-level locking- Returns:
trueif this dialect supports the specified locking options,falseotherwise
-
supportsResultSetReturningAsOutParameter
public boolean supportsResultSetReturningAsOutParameter()Description copied from interface:DialectDetermines whether this dialect supports result sets as OUT parameters in stored procedures.Some database systems allow stored procedures to return result sets through OUT parameters, while others use different mechanisms (like returning result sets directly).
- Specified by:
supportsResultSetReturningAsOutParameterin interfaceDialect- Returns:
trueif this dialect supports result sets as OUT parameters,falseotherwise
-
getResultSetType
Description copied from interface:DialectReturns theJdbcTypeobject that corresponds to theResultSetclass.This method is available, only if
Dialect.supportsResultSetReturningAsOutParameter()istrue.- Specified by:
getResultSetTypein interfaceDialect- Returns:
- the
JdbcTypeobject for theResultSetclass
-
getIdentitySelectSql
public Sql<?> getIdentitySelectSql(String catalogName, String schemaName, String tableName, String columnName, boolean isQuoteRequired, boolean isIdColumnQuoteRequired) Description copied from interface:DialectReturns an SQL object to retrieve IDENTITY values that were generated during an insert operation.This method is used to create the SQL statement that retrieves the last generated identity value for a specific table and column.
This method is available only if
Dialect.supportsIdentity()returnstrue.- Specified by:
getIdentitySelectSqlin interfaceDialect- Parameters:
catalogName- the catalog name of the table (may benullif not applicable)schemaName- the schema name of the table (may benullif not applicable)tableName- the name of the table containing the identity columncolumnName- the name of the identity columnisQuoteRequired- whether the table name should be quoted in the SQL statementisIdColumnQuoteRequired- whether the identity column name should be quoted in the SQL statement- Returns:
- the SQL object that can be executed to retrieve the generated identity value
-
getIdentityReservationSql
public Sql<?> getIdentityReservationSql(String catalogName, String schemaName, String tableName, String columnName, boolean isQuoteRequired, boolean isIdColumnQuoteRequired, int reservationSize) Description copied from interface:DialectReturns an SQL object to reserve identity in the database.This method is available, only if
Dialect.supportsIdentityReservation()returnstrue.- Specified by:
getIdentityReservationSqlin interfaceDialect- Parameters:
catalogName- the catalog nameschemaName- the schema nametableName- the table namecolumnName- the IDENTITY column nameisQuoteRequired- whether the quotation marks are requiredisIdColumnQuoteRequired- whether the quotation marks are required for the IDENTITY columnreservationSize- the size of the reservation- Returns:
- the SQL object
-
getSequenceNextValSql
Description copied from interface:DialectReturns an SQL object to retrieve the next value from a database sequence.This method creates the SQL statement needed to get the next value from a sequence.
The allocation size parameter can be used to optimize sequence access by retrieving multiple values at once in database systems that support this feature.
This method is available only if
Dialect.supportsSequence()returnstrue.- Specified by:
getSequenceNextValSqlin interfaceDialect- Parameters:
qualifiedSequenceName- the fully qualified name of the sequence, which may include catalog and schema information depending on the database systemallocationSize- the number of sequence values to allocate at once for optimization; a value greater than 1 may improve performance by reducing database calls- Returns:
- the SQL object that can be executed to retrieve the next sequence value(s)
-
applyQuote
Description copied from interface:DialectEncloses the name with quotation marks.- Specified by:
applyQuotein interfaceDialect- Parameters:
name- the name of a database object such as a table, a column, and so on- Returns:
- the name that is enclosed with quotation marks
-
removeQuote
Description copied from interface:DialectRemoves quotation marks from the name- Specified by:
removeQuotein interfaceDialect- Parameters:
name- the name of a database object such as a table, a column, and so on- Returns:
- the name that has no enclosing quotation marks
-
getJdbcMappingVisitor
Description copied from interface:Dialect- Specified by:
getJdbcMappingVisitorin interfaceDialect- Returns:
- the visitor
-
getSqlLogFormattingVisitor
Description copied from interface:DialectReturns the visitor that mapsWrappertoSqlLogFormatter.- Specified by:
getSqlLogFormattingVisitorin interfaceDialect- Returns:
- the visitor
-
getExpressionFunctions
Description copied from interface:DialectReturns the aggregation of the expression functions that are available in the SQL templates.- Specified by:
getExpressionFunctionsin interfaceDialect- Returns:
- the aggregation of the expression functions
-
createScriptBlockContext
Description copied from interface:DialectCreates the context object to process an SQL block in a script.- Specified by:
createScriptBlockContextin interfaceDialect- Returns:
- the context object
-
getScriptBlockDelimiter
Description copied from interface:DialectReturns the delimiter that is used as the end of an SQL block in a script.- Specified by:
getScriptBlockDelimiterin interfaceDialect- Returns:
- the delimiter
-
getAutoGeneratedKeysType
Description copied from interface:DialectReturns the type of the auto generated keys.- Specified by:
getAutoGeneratedKeysTypein interfaceDialect- Returns:
- the type of the auto generated keys
-
getCriteriaBuilder
Description copied from interface:DialectReturns the criteria builder for this dialect.The criteria builder is used to construct SQL queries using the criteria API, which provides a type-safe way to build queries programmatically. The returned builder will generate SQL that is compatible with the specific database dialect.
- Specified by:
getCriteriaBuilderin interfaceDialect- Returns:
- the criteria builder for this dialect
-
getUpsertAssembler
Description copied from interface:DialectReturns the UpsertAssembler implementation for the given context.- Specified by:
getUpsertAssemblerin interfaceDialect- Parameters:
context- the UpsertAssemblerContext object- Returns:
- the UpsertAssembler object for the given context
-
getMultiInsertAssembler
public <ENTITY> MultiInsertAssembler getMultiInsertAssembler(MultiInsertAssemblerContext<ENTITY> context) Description copied from interface:DialectProvides an implementation ofMultiInsertAssemblerbased on the given context.- Specified by:
getMultiInsertAssemblerin interfaceDialect- Type Parameters:
ENTITY- the type of the entity to be handled by the assembler- Parameters:
context- the context that holds the information required to create theMultiInsertAssembler- Returns:
- an instance of
MultiInsertAssemblerspecific to the provided entity context
-
getInsertAssembler
Description copied from interface:DialectProvides an implementation ofInsertAssemblerbased on the given context.- Specified by:
getInsertAssemblerin interfaceDialect- Type Parameters:
ENTITY- the type of the entity to be handled by the assembler- Parameters:
context- the context that holds the information required to create theInsertAssembler- Returns:
- an instance of
InsertAssemblerspecific to the provided entity context
-
getUpdateAssembler
Description copied from interface:DialectProvides an implementation ofUpdateAssemblerbased on the given context.- Specified by:
getUpdateAssemblerin interfaceDialect- Type Parameters:
ENTITY- the type of the entity to be handled by the assembler- Parameters:
context- the context that holds the information required to create theUpdateAssembler- Returns:
- an instance of
UpdateAssemblerspecific to the provided entity context
-
getDeleteAssembler
Description copied from interface:DialectProvides an implementation ofDeleteAssemblerbased on the given context.- Specified by:
getDeleteAssemblerin interfaceDialect- Type Parameters:
ENTITY- the type of the entity to be handled by the assembler- Parameters:
context- the context that holds the information required to create theDeleteAssembler- Returns:
- an instance of
DeleteAssemblerspecific to the provided entity context
-