java.lang.Object
org.seasar.doma.jdbc.query.AbstractQuery
org.seasar.doma.jdbc.query.SqlFileModifyQuery
- All Implemented Interfaces:
ModifyQuery,Query
- Direct Known Subclasses:
SqlFileDeleteQuery,SqlFileInsertQuery,SqlFileUpdateQuery
An abstract base class for SQL file-based data modification queries.
This class provides common functionality for SQL file-based INSERT, UPDATE, and DELETE operations. It handles SQL file loading, parameter binding, and SQL statement preparation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String[]Empty string array used as default for property name arrays.protected String[]The property names to be excluded from the operation.protected booleanWhether this query is executable.protected String[]The property names to be included in the operation.protected 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 SqlExecutionSkipCauseThe cause for skipping SQL execution, if applicable.protected StringThe path to the SQL file.protected SqlLogTypeThe SQL log type for this query.Fields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlFileModifyQuery(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.voidaddParameterInternal(String name, Class<?> type, Object value) Adds a parameter to this query without null checks.expandColumns(ExpandNode node) Expands columns in the SQL statement.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.protected voidpopulateValues(PopulateNode node, SqlContext context) Populates values in the SQL context.protected voidPrepares the query options.protected voidPrepares the SQL statement.abstract <E> voidsetEntityAndEntityType(String name, E entity, EntityType<E> entityType) Sets the entity and entity type for this query.voidsetExcludedPropertyNames(String... excludedPropertyNames) Sets the property names to be excluded from the operation.voidsetIncludedPropertyNames(String... includedPropertyNames) Sets the property names to be included in the operation.voidsetSqlFilePath(String sqlFilePath) Sets the path to the SQL file.voidsetSqlLogType(SqlLogType sqlLogType) Sets the SQL log type for this query.toString()Methods inherited from class org.seasar.doma.jdbc.query.AbstractQuery
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout, prepare, 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, complete, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout, prepare
-
Field Details
-
EMPTY_STRINGS
Empty string array used as default for property name arrays. -
kind
The SQL kind (INSERT, UPDATE, or DELETE). -
sqlFilePath
The path to the SQL file. -
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. -
includedPropertyNames
The property names to be included in the operation. -
excludedPropertyNames
The property names to be excluded from the operation. -
executable
protected boolean executableWhether this query is executable. -
sqlExecutionSkipCause
The cause for skipping SQL execution, if applicable.
-
-
Constructor Details
-
SqlFileModifyQuery
Constructs a new instance with the specified SQL kind.- Parameters:
kind- the SQL kind
-
-
Method Details
-
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 loads the SQL file, evaluates expressions, and builds the prepared SQL statement.
-
expandColumns
Expands columns in the SQL statement.This method is called when an expand node is encountered in the SQL file.
- Parameters:
node- the expand node- Returns:
- the expanded column list
- Throws:
UnsupportedOperationException- if this operation is not supported by the implementing class
-
populateValues
Populates values in the SQL context.This method is called when a populate node is encountered in the SQL file.
- Parameters:
node- the populate nodecontext- the SQL context- Throws:
UnsupportedOperationException- if this operation is not supported by the implementing class
-
setSqlFilePath
Sets the path to the SQL file.- Parameters:
sqlFilePath- the SQL file path
-
addParameter
Adds a parameter to this query.- Parameters:
name- the parameter nametype- the parameter typevalue- the parameter value
-
addParameterInternal
Adds a parameter to this query without null checks.This method is used internally when null checks have already been performed.
- Parameters:
name- the parameter nametype- the parameter typevalue- the parameter value
-
setSqlLogType
Sets the SQL log type for this query.- Parameters:
sqlLogType- the SQL log type
-
setIncludedPropertyNames
Sets the property names to be included in the operation.- Parameters:
includedPropertyNames- the property names to be included
-
setExcludedPropertyNames
Sets the property names to be excluded from the operation.- Parameters:
excludedPropertyNames- the property names to be excluded
-
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
-
setEntityAndEntityType
Sets the entity and entity type for this query.- Type Parameters:
E- the entity type- Parameters:
name- the parameter name for the entityentity- the entityentityType- the entity type
-
toString
-