Class SqlFileBatchInsertQuery<ELEMENT>

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

public class SqlFileBatchInsertQuery<ELEMENT> extends SqlFileBatchModifyQuery<ELEMENT> implements BatchInsertQuery
A query that performs batch insert operations using an external SQL file.

This class extends SqlFileBatchModifyQuery to provide functionality for executing batch INSERT statements defined in external SQL files. It handles entity lifecycle callbacks and SQL file execution for multiple entities.

  • Field Details

  • Constructor Details

    • SqlFileBatchInsertQuery

      public SqlFileBatchInsertQuery(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-insert callbacks.

      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class SqlFileBatchModifyQuery<ELEMENT>
    • preInsert

      protected void preInsert()
      Executes pre-insert entity lifecycle callbacks.

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

    • generateId

      public void generateId(Statement statement, int index)
      Generates an ID for a single inserted row in the batch.

      This method is called after executing the batch to generate IDs for rows that use auto-generated keys or sequences.

      This implementation does nothing because this query does not support auto-generated keys.

      Specified by:
      generateId in interface BatchInsertQuery
      Parameters:
      statement - the statement used for the batch operation
      index - the index of the element in the batch
    • complete

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

      This implementation executes post-insert 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
    • isBatchSupported

      public boolean isBatchSupported()
      Determines if batch operations are supported for this query.

      Some database operations or configurations may not support batch processing. This method allows implementations to indicate whether batch operations can be used.

      Specified by:
      isBatchSupported in interface BatchInsertQuery
      Returns:
      true if batch operations are supported, false otherwise