Class SqlFileBatchUpdateQuery<ELEMENT>
- Type Parameters:
ELEMENT- the type of elements in the batch
- All Implemented Interfaces:
BatchModifyQuery,BatchUpdateQuery,Query
This class extends SqlFileBatchModifyQuery to provide functionality for executing
batch UPDATE statements defined in external SQL files. It handles entity lifecycle callbacks,
optimistic locking, version incrementation, and SQL file execution for multiple entities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA handler for entity lifecycle callbacks, optimistic locking, and value population.protected static classA context for post-update entity lifecycle callbacks.protected static classA context for pre-update entity lifecycle callbacks. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SqlFileBatchUpdateQuery<ELEMENT>.EntityHandlerThe entity handler for this query.protected booleanWhether to suppress optimistic lock exceptions.protected booleanWhether to ignore the version property for optimistic locking.Fields inherited from class org.seasar.doma.jdbc.query.SqlFileBatchModifyQuery
batchSize, currentEntity, elementClass, elements, EMPTY_STRINGS, excludedPropertyNames, executable, includedPropertyNames, kind, optimisticLockCheckRequired, parameterName, sqlExecutionSkipCause, sqlFile, sqlFilePath, sqlLogType, sqlsFields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
ConstructorsConstructorDescriptionSqlFileBatchUpdateQuery(Class<ELEMENT> elementClass) Constructs a new instance with the specified element class. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Completes this query after execution.voidIncrements the version numbers for all entities in the batch.protected voidInitializes the entity handler.protected voidpopulateValues(PopulateNode node, SqlContext context) Populates values in the SQL context.voidprepare()Prepares this query for execution.protected voidPrepares optimistic locking for this query.protected voidPrepares the target property types for this query.protected voidExecutes pre-update entity lifecycle callbacks.voidsetEntityType(EntityType<ELEMENT> entityType) Sets the entity type for this query.voidsetOptimisticLockExceptionSuppressed(boolean optimisticLockExceptionSuppressed) Sets whether to suppress optimistic lock exceptions.voidsetVersionIgnored(boolean versionIgnored) Sets whether to ignore the version property for optimistic locking.voidsetVersionIncluded(boolean versionIncluded) Sets whether to include the version property in the update.Methods inherited from class org.seasar.doma.jdbc.query.SqlFileBatchModifyQuery
expandColumns, getBatchSize, getConfig, getEntities, getSql, getSqlExecutionSkipCause, getSqlLogType, getSqls, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequired, prepareOptions, prepareSql, prepareSqlFile, setBatchSize, setElements, setExcludedPropertyNames, setIncludedPropertyNames, setParameterName, setSqlFilePath, setSqlLogType, toStringMethods inherited from class org.seasar.doma.jdbc.query.AbstractQuery
comment, getClassName, 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.BatchModifyQuery
getBatchSize, getSql, getSqlExecutionSkipCause, getSqlLogType, getSqls, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequiredMethods inherited from interface org.seasar.doma.jdbc.query.Query
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout
-
Field Details
-
entityHandler
The entity handler for this query. -
versionIgnored
protected boolean versionIgnoredWhether to ignore the version property for optimistic locking. -
optimisticLockExceptionSuppressed
protected boolean optimisticLockExceptionSuppressedWhether to suppress optimistic lock exceptions.
-
-
Constructor Details
-
SqlFileBatchUpdateQuery
Constructs a new instance with the specified element class.- Parameters:
elementClass- the class of elements in the batch
-
-
Method Details
-
prepare
public void prepare()Prepares this query for execution. This method must be called before the query is executed.This implementation validates that required components are not null.
This implementation prepares the SQL statements for each entity in the batch, executing pre-update callbacks, optimistic lock preparation, and target property type preparation.
- Specified by:
preparein interfaceQuery- Overrides:
preparein classSqlFileBatchModifyQuery<ELEMENT>
-
initEntityHandler
protected void initEntityHandler()Initializes the entity handler.This method delegates to the entity handler if one is available.
-
preUpdate
protected void preUpdate()Executes pre-update entity lifecycle callbacks.This method delegates to the entity handler if one is available.
-
prepareTargetPropertyTypes
protected void prepareTargetPropertyTypes()Prepares the target property types for this query.This method delegates to the entity handler if one is available.
-
populateValues
Populates values in the SQL context.This method is called when a populate node is encountered in the SQL file.
This implementation delegates to the entity handler to populate values in the SQL context.
- Overrides:
populateValuesin classSqlFileBatchModifyQuery<ELEMENT>- Parameters:
node- the populate nodecontext- the SQL context- Throws:
UnsupportedOperationException- if the entity handler is not available
-
prepareOptimisticLock
protected void prepareOptimisticLock()Prepares optimistic locking for this query.This method delegates to the entity handler if one is available.
-
incrementVersions
public void incrementVersions()Increments the version numbers for all entities in the batch.This method is called after executing the batch to update the version numbers in the entity objects, ensuring they match the values in the database after the update. This is important for optimistic concurrency control.
This implementation delegates to the entity handler to increment version values for optimistic locking.
- Specified by:
incrementVersionsin interfaceBatchUpdateQuery
-
complete
public void complete()Completes this query after execution. This method must be called after the query is executed.This implementation executes post-update entity lifecycle callbacks for each entity in the batch.
-
setEntityType
Sets the entity type for this query.This implementation creates an entity handler for the specified entity type.
- Specified by:
setEntityTypein classSqlFileBatchModifyQuery<ELEMENT>- Parameters:
entityType- the entity type
-
setVersionIncluded
public void setVersionIncluded(boolean versionIncluded) Sets whether to include the version property in the update.- Parameters:
versionIncluded- whether to include the version property
-
setVersionIgnored
public void setVersionIgnored(boolean versionIgnored) Sets whether to ignore the version property for optimistic locking.- Parameters:
versionIgnored- whether to ignore the version property
-
setOptimisticLockExceptionSuppressed
public void setOptimisticLockExceptionSuppressed(boolean optimisticLockExceptionSuppressed) Sets whether to suppress optimistic lock exceptions.- Parameters:
optimisticLockExceptionSuppressed- whether to suppress optimistic lock exceptions
-