- Type Parameters:
ENTITY- the entity type
- All Implemented Interfaces:
BatchDeleteQuery,BatchModifyQuery,Query
This class implements BatchDeleteQuery to provide batch DELETE operations for
entities. It handles version checking for optimistic locking and supports tenant ID-based
isolation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe context class for post-delete processing in batch operations.protected static classThe context class for pre-delete processing in batch operations. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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.AutoBatchModifyQuery
autoGeneratedKeysSupported, batchSize, currentEntity, EMPTY_STRINGS, entities, entityType, excludedPropertyNames, executable, idPropertyTypes, includedPropertyNames, optimisticLockCheckRequired, sqlExecutionSkipCause, sqlLogType, sqls, targetPropertyTypes, tenantIdPropertyType, versionPropertyTypeFields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Completes this query after execution.protected voidExecutes post-delete processing for the current entity.protected voidExecutes pre-delete processing for the current entity.voidprepare()Prepares this query for execution.protected voidPrepares optimistic locking settings for this query.protected voidPrepares the SQL statement for the current entity.voidsetOptimisticLockExceptionSuppressed(boolean optimisticLockExceptionSuppressed) Sets whether to suppress optimistic lock exceptions.voidsetVersionIgnored(boolean versionIgnored) Sets whether to ignore the version property for optimistic locking.Methods inherited from class org.seasar.doma.jdbc.query.AutoBatchModifyQuery
getBatchSize, getEntities, getSql, getSqlExecutionSkipCause, getSqlLogType, getSqls, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequired, isTargetPropertyName, prepareIdAndVersionPropertyTypes, prepareOptions, setBatchSize, setEntities, setExcludedPropertyNames, setIncludedPropertyNames, setSqlLogType, toString, validateIdExistentMethods 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.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
-
versionIgnored
protected boolean versionIgnoredWhether to ignore the version property for optimistic locking. -
optimisticLockExceptionSuppressed
protected boolean optimisticLockExceptionSuppressedWhether to suppress optimistic lock exceptions.
-
-
Constructor Details
-
AutoBatchDeleteQuery
Constructs an instance.- Parameters:
entityType- the entity type
-
-
Method Details
-
prepare
public void prepare()Prepares this query for execution.This method validates the state of this instance, prepares SQL statements for all entities, and ensures that the number of SQL statements matches the number of entities.
- Specified by:
preparein interfaceQuery- Overrides:
preparein classAbstractQuery
-
preDelete
protected void preDelete()Executes pre-delete processing for the current entity.This method creates a context for pre-delete operations and calls the entity type's preDelete method. If a new entity is returned by the context, it replaces the current entity.
-
prepareOptimisticLock
protected void prepareOptimisticLock()Prepares optimistic locking settings for this query.This method sets the optimistic lock check flag based on the version property type and the configuration settings for version handling and exception suppression.
-
prepareSql
protected void prepareSql()Prepares the SQL statement for the current entity.This method builds a DELETE SQL statement with appropriate WHERE clauses for ID properties, version property (for optimistic locking), and tenant ID property (for multi-tenancy). The completed SQL statement is added to the list of SQL statements to be executed.
-
complete
public void complete()Completes this query after execution.This method performs post-processing for all entities after the batch delete operation has been executed. It calls the postDelete method for each entity.
-
postDelete
protected void postDelete()Executes post-delete processing for the current entity.This method creates a context for post-delete operations and calls the entity type's postDelete method. If a new entity is returned by the context, it replaces the current entity.
-
setVersionIgnored
public void setVersionIgnored(boolean versionIgnored) Sets whether to ignore the version property for optimistic locking.- Parameters:
versionIgnored- true to ignore the version property, false otherwise
-
setOptimisticLockExceptionSuppressed
public void setOptimisticLockExceptionSuppressed(boolean optimisticLockExceptionSuppressed) Sets whether to suppress optimistic lock exceptions.- Parameters:
optimisticLockExceptionSuppressed- true to suppress optimistic lock exceptions, false otherwise
-