Class Db2Dialect

java.lang.Object
org.seasar.doma.jdbc.dialect.StandardDialect
org.seasar.doma.jdbc.dialect.Db2Dialect
All Implemented Interfaces:
Dialect

public class Db2Dialect extends StandardDialect
A dialect for Db2.
  • Field Details

    • UNIQUE_CONSTRAINT_VIOLATION_STATE_CODE

      protected static final String UNIQUE_CONSTRAINT_VIOLATION_STATE_CODE
      the SQLState code that represents unique violation
      See Also:
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from interface: Dialect
      Returns 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.

      Specified by:
      getName in interface Dialect
      Overrides:
      getName in class StandardDialect
      Returns:
      the name of this dialect
    • toForUpdateSqlNode

      protected SqlNode toForUpdateSqlNode(SqlNode sqlNode, SelectForUpdateType forUpdateType, int waitSeconds, String... aliases)
      Overrides:
      toForUpdateSqlNode in class StandardDialect
    • toPagingSqlNode

      protected SqlNode toPagingSqlNode(SqlNode sqlNode, long offset, long limit)
      Overrides:
      toPagingSqlNode in class StandardDialect
    • isUniqueConstraintViolated

      public boolean isUniqueConstraintViolated(SQLException sqlException)
      Description copied from interface: Dialect
      Determines 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:
      isUniqueConstraintViolated in interface Dialect
      Overrides:
      isUniqueConstraintViolated in class StandardDialect
      Parameters:
      sqlException - the SQL exception to analyze
      Returns:
      true if the exception represents a unique constraint violation, false otherwise
    • getSequenceNextValSql

      public PreparedSql getSequenceNextValSql(String qualifiedSequenceName, long allocationSize)
      Description copied from interface: Dialect
      Returns 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() returns true.

      Specified by:
      getSequenceNextValSql in interface Dialect
      Overrides:
      getSequenceNextValSql in class StandardDialect
      Parameters:
      qualifiedSequenceName - the fully qualified name of the sequence, which may include catalog and schema information depending on the database system
      allocationSize - 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)
    • supportsIdentity

      public boolean supportsIdentity()
      Description copied from interface: Dialect
      Determines 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:
      supportsIdentity in interface Dialect
      Overrides:
      supportsIdentity in class StandardDialect
      Returns:
      true if this dialect supports IDENTITY columns, false otherwise
    • supportsSequence

      public boolean supportsSequence()
      Description copied from interface: Dialect
      Determines 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:
      supportsSequence in interface Dialect
      Overrides:
      supportsSequence in class StandardDialect
      Returns:
      true if this dialect supports sequences, false otherwise
    • supportsSelectForUpdate

      public boolean supportsSelectForUpdate(SelectForUpdateType type, boolean withTargets)
      Description copied from interface: Dialect
      Determines 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:
      supportsSelectForUpdate in interface Dialect
      Overrides:
      supportsSelectForUpdate in class StandardDialect
      Parameters:
      type - the type of pessimistic locking (e.g., standard FOR UPDATE, NOWAIT, WAIT)
      withTargets - true if specific columns are targeted for locking, false for row-level locking
      Returns:
      true if this dialect supports the specified locking options, false otherwise
    • supportsAutoGeneratedKeys

      public boolean supportsAutoGeneratedKeys()
      Description copied from interface: Dialect
      Determines whether this dialect supports retrieving auto-generated keys via Statement.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:
      supportsAutoGeneratedKeys in interface Dialect
      Overrides:
      supportsAutoGeneratedKeys in class StandardDialect
      Returns:
      true if this dialect supports retrieving auto-generated keys, false otherwise
    • getScriptBlockDelimiter

      public String getScriptBlockDelimiter()
      Description copied from interface: Dialect
      Returns the delimiter that is used as the end of an SQL block in a script.
      Specified by:
      getScriptBlockDelimiter in interface Dialect
      Overrides:
      getScriptBlockDelimiter in class StandardDialect
      Returns:
      the delimiter
    • createScriptBlockContext

      public ScriptBlockContext createScriptBlockContext()
      Description copied from interface: Dialect
      Creates the context object to process an SQL block in a script.
      Specified by:
      createScriptBlockContext in interface Dialect
      Overrides:
      createScriptBlockContext in class StandardDialect
      Returns:
      the context object
    • getCriteriaBuilder

      public CriteriaBuilder getCriteriaBuilder()
      Description copied from interface: Dialect
      Returns 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:
      getCriteriaBuilder in interface Dialect
      Overrides:
      getCriteriaBuilder in class StandardDialect
      Returns:
      the criteria builder for this dialect