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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final SqlKindThe SQL kind (INSERT, UPDATE, or DELETE).protected booleanWhether optimistic lock checking is required for this query.The parameters to be bound to the SQL statement.protected PreparedSqlThe prepared SQL statement.protected SqlLogTypeThe SQL log type for this query.protected SqlNodeThe SQL node representing the query.Fields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlModifyQuery(SqlKind kind) Constructs a new instance with the specified SQL kind. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameter(String name, Class<?> type, Object value) Adds a parameter to this query.voidClears all parameters from this query.voidcomplete()Completes this query after execution.getSql()Returns the prepared SQL for this modification query.Returns the cause if SQL execution should be skipped.Returns the SQL log type for this query.booleanReturns whether auto-generated keys are supported for this query.booleanReturns whether this query is executable.booleanReturns whether optimistic lock checking is required for this query.voidprepare()Prepares this query for execution.protected voidPrepares the query options.protected voidPrepares the SQL statement.voidsetSqlLogType(SqlLogType sqlLogType) Sets the SQL log type for this query.voidsetSqlNode(SqlNode sqlNode) Sets the SQL node for this query.toString()Methods inherited from class org.seasar.doma.jdbc.query.AbstractQuery
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout, setCallerClassName, setCallerMethodName, setConfig, setMessage, setMethod, setQueryTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.seasar.doma.jdbc.query.Query
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout
-
Field Details
-
kind
The SQL kind (INSERT, UPDATE, or DELETE). -
sqlNode
The SQL node representing the query. -
parameters
The parameters to be bound to the SQL statement. -
sql
The prepared SQL statement. -
optimisticLockCheckRequired
protected boolean optimisticLockCheckRequiredWhether optimistic lock checking is required for this query. -
sqlLogType
The SQL log type for this query.
-
-
Constructor Details
-
SqlModifyQuery
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:
preparein interfaceQuery- Overrides:
preparein classAbstractQuery
-
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. -
setSqlNode
Sets the SQL node for this query.- Parameters:
sqlNode- the SQL node
-
addParameter
Adds a parameter to this query.- Parameters:
name- the parameter nametype- the parameter typevalue- the parameter value
-
clearParameters
public void clearParameters()Clears all parameters from this query. -
setSqlLogType
Sets the SQL log type for this query.- Parameters:
sqlLogType- the SQL log type
-
getSql
Returns the prepared SQL for this modification query.- Specified by:
getSqlin interfaceModifyQuery- Specified by:
getSqlin interfaceQuery- Returns:
- the prepared SQL
-
isOptimisticLockCheckRequired
public boolean isOptimisticLockCheckRequired()Returns whether optimistic lock checking is required for this query.- Specified by:
isOptimisticLockCheckRequiredin interfaceModifyQuery- Returns:
trueif optimistic lock checking is required
-
isExecutable
public boolean isExecutable()Returns whether this query is executable.- Specified by:
isExecutablein interfaceModifyQuery- Returns:
trueif this query is executable
-
getSqlExecutionSkipCause
Returns the cause if SQL execution should be skipped.- Specified by:
getSqlExecutionSkipCausein interfaceModifyQuery- Returns:
- the cause of SQL execution skip, or
nullif execution should not be skipped
-
isAutoGeneratedKeysSupported
public boolean isAutoGeneratedKeysSupported()Returns whether auto-generated keys are supported for this query.- Specified by:
isAutoGeneratedKeysSupportedin interfaceModifyQuery- Returns:
trueif auto-generated keys are supported
-
getSqlLogType
Returns the SQL log type for this query.- Specified by:
getSqlLogTypein interfaceModifyQuery- Returns:
- the SQL log type
-
toString
-