Class SqlFileDeleteQuery

All Implemented Interfaces:
DeleteQuery, ModifyQuery, Query

public class SqlFileDeleteQuery extends SqlFileModifyQuery implements DeleteQuery
A query that deletes data from a database using an external SQL file.

This class extends SqlFileModifyQuery to provide functionality for executing DELETE statements defined in external SQL files. It handles entity lifecycle callbacks, optimistic locking, and SQL file execution.

  • Field Details

    • entityHandler

      protected SqlFileDeleteQuery.EntityHandler<?> entityHandler
      The entity handler for this query.
    • 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

    • SqlFileDeleteQuery

      public SqlFileDeleteQuery()
      Constructs a new instance.

      This constructor initializes the query with SqlKind.DELETE to indicate that it performs a DELETE operation.

  • Method Details

    • prepare

      public void prepare()
      Prepares this query for execution. This method must be called before the query is executed.

      This implementation prepares the SQL statement by processing the SQL file and handling entity lifecycle callbacks and optimistic locking.

      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class AbstractQuery
    • preDelete

      protected void preDelete()
      Executes pre-delete entity lifecycle callbacks.

      This method delegates to the entity handler if one is available.

    • prepareOptimisticLock

      protected void prepareOptimisticLock()
      Prepares optimistic locking for this query.

      This method delegates to the entity handler if one is available.

    • prepareExecutable

      protected void prepareExecutable()
      Prepares the executable state for this query.

      This method sets the query as executable and clears any skip cause.

    • complete

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

      This implementation executes post-delete entity lifecycle callbacks.

      Specified by:
      complete in interface Query
    • setEntityAndEntityType

      public <E> void setEntityAndEntityType(String name, E entity, EntityType<E> entityType)
      Sets the entity and entity type for this query.

      This implementation creates an entity handler for the specified entity.

      Specified by:
      setEntityAndEntityType in class SqlFileModifyQuery
      Type Parameters:
      E - the entity type
      Parameters:
      name - the parameter name for the entity
      entity - the entity
      entityType - the entity type
    • 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
    • getEntity

      public <E> E getEntity(Class<E> entityType)
      Returns the entity associated with this query.
      Type Parameters:
      E - the entity type
      Parameters:
      entityType - the entity class
      Returns:
      the entity, or null if no entity is associated with this query