Class SqlFileBatchUpdateQuery<ELEMENT>

java.lang.Object
org.seasar.doma.jdbc.query.AbstractQuery
org.seasar.doma.jdbc.query.SqlFileBatchModifyQuery<ELEMENT>
org.seasar.doma.jdbc.query.SqlFileBatchUpdateQuery<ELEMENT>
Type Parameters:
ELEMENT - the type of elements in the batch
All Implemented Interfaces:
BatchModifyQuery, BatchUpdateQuery, Query

public class SqlFileBatchUpdateQuery<ELEMENT> extends SqlFileBatchModifyQuery<ELEMENT> implements BatchUpdateQuery
A query that performs batch update operations using an external SQL file.

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.

  • Field Details

    • entityHandler

      protected SqlFileBatchUpdateQuery<ELEMENT>.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

    • SqlFileBatchUpdateQuery

      public SqlFileBatchUpdateQuery(Class<ELEMENT> elementClass)
      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:
      prepare in interface Query
      Overrides:
      prepare in class SqlFileBatchModifyQuery<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

      protected void populateValues(PopulateNode node, SqlContext context)
      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:
      populateValues in class SqlFileBatchModifyQuery<ELEMENT>
      Parameters:
      node - the populate node
      context - 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:
      incrementVersions in interface BatchUpdateQuery
    • 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.

      Specified by:
      complete in interface Query
    • setEntityType

      public void setEntityType(EntityType<ELEMENT> entityType)
      Sets the entity type for this query.

      This implementation creates an entity handler for the specified entity type.

      Specified by:
      setEntityType in class SqlFileBatchModifyQuery<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