Class AutoBatchDeleteQuery<ENTITY>

Type Parameters:
ENTITY - the entity type
All Implemented Interfaces:
BatchDeleteQuery, BatchModifyQuery, Query

public class AutoBatchDeleteQuery<ENTITY> extends AutoBatchModifyQuery<ENTITY> implements BatchDeleteQuery
An auto batch delete query that is executed against an entity class.

This class implements BatchDeleteQuery to provide batch DELETE operations for entities. It handles version checking for optimistic locking and supports tenant ID-based isolation.

  • Field Details

    • versionIgnored

      protected boolean versionIgnored
      Whether to ignore the version property for optimistic locking.
    • optimisticLockExceptionSuppressed

      protected boolean optimisticLockExceptionSuppressed
      Whether to suppress optimistic lock exceptions.
  • Constructor Details

    • AutoBatchDeleteQuery

      public AutoBatchDeleteQuery(EntityType<ENTITY> entityType)
      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:
      prepare in interface Query
      Overrides:
      prepare in class AbstractQuery
    • 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.

      Specified by:
      complete in interface Query
    • 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