Class AutoDeleteQuery<ENTITY>

Type Parameters:
ENTITY - the entity type
All Implemented Interfaces:
DeleteQuery, ModifyQuery, Query

public class AutoDeleteQuery<ENTITY> extends AutoModifyQuery<ENTITY> implements DeleteQuery
An auto delete query that is executed against an entity class.

This class implements DeleteQuery to provide 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

    • AutoDeleteQuery

      public AutoDeleteQuery(EntityType<ENTITY> entityType)
      Creates a new instance with the specified entity type.
      Parameters:
      entityType - the entity type
  • Method Details

    • prepare

      public void prepare()
      Prepares this query for execution.

      This method performs basic preparation steps and validates that the dialect supports returning properties if they are specified.

      Subclasses should override this method to perform additional preparation steps, but must call super.prepare() first.

      This implementation prepares the query for execution by performing pre-delete operations, preparing special property types, validating ID existence, preparing options and optimistic locking, and building the SQL statement.

      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class AutoModifyQuery<ENTITY>
    • preDelete

      protected void preDelete()
      Performs pre-delete operations on the entity. This method is called before the entity is deleted from the database.
    • prepareOptimisticLock

      protected void prepareOptimisticLock()
      Prepares optimistic locking for this query. If a version property exists and is not ignored, optimistic lock checking will be enabled unless it is explicitly suppressed.
    • prepareSql

      protected void prepareSql()
      Prepares the SQL statement for this query. This method builds a DELETE statement using the entity type and its properties.
    • complete

      public void complete()
      Completes this query after execution. This method must be called after the query is executed.

      This implementation performs post-delete operations on the entity.

      Specified by:
      complete in interface Query
    • postDelete

      protected void postDelete()
      Performs post-delete operations on the entity. This method is called after the entity is deleted from the database.
    • setVersionIgnored

      public void setVersionIgnored(boolean versionIgnored)
      Sets whether to ignore the version property for optimistic locking.
      Parameters:
      versionIgnored - true to ignore the version property
    • setOptimisticLockExceptionSuppressed

      public void setOptimisticLockExceptionSuppressed(boolean optimisticLockExceptionSuppressed)
      Sets whether to suppress optimistic lock exceptions.
      Parameters:
      optimisticLockExceptionSuppressed - true to suppress optimistic lock exceptions