Class SqlModifyQuery

java.lang.Object
org.seasar.doma.jdbc.query.AbstractQuery
org.seasar.doma.jdbc.query.SqlModifyQuery
All Implemented Interfaces:
ModifyQuery, Query
Direct Known Subclasses:
SqlDeleteQuery, SqlInsertQuery, SqlUpdateQuery

public abstract class SqlModifyQuery extends AbstractQuery implements ModifyQuery
An abstract base class for SQL-based data modification queries.

This class provides common functionality for SQL-based INSERT, UPDATE, and DELETE operations. It handles SQL node processing, parameter binding, and SQL statement preparation.

  • Field Details

    • kind

      protected final SqlKind kind
      The SQL kind (INSERT, UPDATE, or DELETE).
    • sqlNode

      protected SqlNode sqlNode
      The SQL node representing the query.
    • parameters

      protected final Map<String,Value> parameters
      The parameters to be bound to the SQL statement.
    • sql

      protected PreparedSql sql
      The prepared SQL statement.
    • optimisticLockCheckRequired

      protected boolean optimisticLockCheckRequired
      Whether optimistic lock checking is required for this query.
    • sqlLogType

      protected SqlLogType sqlLogType
      The SQL log type for this query.
  • Constructor Details

    • SqlModifyQuery

      protected SqlModifyQuery(SqlKind kind)
      Constructs a new instance with the specified SQL kind.
      Parameters:
      kind - the SQL kind
  • Method Details

    • prepare

      public void prepare()
      Prepares this query for execution. This method must be called before the query is executed.

      This implementation prepares the SQL statement by processing the SQL node and binding parameters.

      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class AbstractQuery
    • prepareOptions

      protected void prepareOptions()
      Prepares the query options.

      This method sets the query timeout from the configuration if it's not already set.

    • prepareSql

      protected void prepareSql()
      Prepares the SQL statement.

      This method evaluates expressions in the SQL node and builds the prepared SQL statement.

    • complete

      public void complete()
      Completes this query after execution. This method must be called after the query is executed.
      Specified by:
      complete in interface Query
    • setSqlNode

      public void setSqlNode(SqlNode sqlNode)
      Sets the SQL node for this query.
      Parameters:
      sqlNode - the SQL node
    • addParameter

      public void addParameter(String name, Class<?> type, Object value)
      Adds a parameter to this query.
      Parameters:
      name - the parameter name
      type - the parameter type
      value - the parameter value
    • clearParameters

      public void clearParameters()
      Clears all parameters from this query.
    • setSqlLogType

      public void setSqlLogType(SqlLogType sqlLogType)
      Sets the SQL log type for this query.
      Parameters:
      sqlLogType - the SQL log type
    • getSql

      public PreparedSql getSql()
      Returns the prepared SQL for this modification query.
      Specified by:
      getSql in interface ModifyQuery
      Specified by:
      getSql in interface Query
      Returns:
      the prepared SQL
    • isOptimisticLockCheckRequired

      public boolean isOptimisticLockCheckRequired()
      Returns whether optimistic lock checking is required for this query.
      Specified by:
      isOptimisticLockCheckRequired in interface ModifyQuery
      Returns:
      true if optimistic lock checking is required
    • isExecutable

      public boolean isExecutable()
      Returns whether this query is executable.
      Specified by:
      isExecutable in interface ModifyQuery
      Returns:
      true if this query is executable
    • getSqlExecutionSkipCause

      public SqlExecutionSkipCause getSqlExecutionSkipCause()
      Returns the cause if SQL execution should be skipped.
      Specified by:
      getSqlExecutionSkipCause in interface ModifyQuery
      Returns:
      the cause of SQL execution skip, or null if execution should not be skipped
    • isAutoGeneratedKeysSupported

      public boolean isAutoGeneratedKeysSupported()
      Returns whether auto-generated keys are supported for this query.
      Specified by:
      isAutoGeneratedKeysSupported in interface ModifyQuery
      Returns:
      true if auto-generated keys are supported
    • getSqlLogType

      public SqlLogType getSqlLogType()
      Returns the SQL log type for this query.
      Specified by:
      getSqlLogType in interface ModifyQuery
      Returns:
      the SQL log type
    • toString

      public String toString()
      Overrides:
      toString in class Object