Class SqlFileBatchInsertQuery<ELEMENT>
- Type Parameters:
ELEMENT- the type of elements in the batch
- All Implemented Interfaces:
BatchInsertQuery,BatchModifyQuery,Query
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA handler for entity lifecycle callbacks.protected static classA context for post-insert entity lifecycle callbacks.protected static classA context for pre-insert entity lifecycle callbacks. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SqlFileBatchInsertQuery<ELEMENT>.EntityHandlerThe entity handler for this query.Fields inherited from class org.seasar.doma.jdbc.query.SqlFileBatchModifyQuery
batchSize, currentEntity, elementClass, elements, EMPTY_STRINGS, excludedPropertyNames, executable, includedPropertyNames, kind, optimisticLockCheckRequired, parameterName, sqlExecutionSkipCause, sqlFile, sqlFilePath, sqlLogType, sqlsFields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
ConstructorsConstructorDescriptionSqlFileBatchInsertQuery(Class<ELEMENT> elementClass) Constructs a new instance with the specified element class. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Completes this query after execution.voidgenerateId(Statement statement, int index) Generates an ID for a single inserted row in the batch.booleanDetermines if batch operations are supported for this query.protected voidExecutes pre-insert entity lifecycle callbacks.voidprepare()Prepares this query for execution.voidsetEntityType(EntityType<ELEMENT> entityType) Sets the entity type for this query.Methods inherited from class org.seasar.doma.jdbc.query.SqlFileBatchModifyQuery
expandColumns, getBatchSize, getConfig, getEntities, getSql, getSqlExecutionSkipCause, getSqlLogType, getSqls, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequired, populateValues, prepareOptions, prepareSql, prepareSqlFile, setBatchSize, setElements, setExcludedPropertyNames, setIncludedPropertyNames, setParameterName, setSqlFilePath, setSqlLogType, toStringMethods inherited from class org.seasar.doma.jdbc.query.AbstractQuery
comment, getClassName, getMethod, getMethodName, getQueryTimeout, setCallerClassName, setCallerMethodName, setConfig, setMessage, setMethod, setQueryTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.seasar.doma.jdbc.query.BatchInsertQuery
generateIdsMethods inherited from interface org.seasar.doma.jdbc.query.BatchModifyQuery
getBatchSize, getSql, getSqlExecutionSkipCause, getSqlLogType, getSqls, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequiredMethods inherited from interface org.seasar.doma.jdbc.query.Query
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout
-
Field Details
-
entityHandler
The entity handler for this query.
-
-
Constructor Details
-
SqlFileBatchInsertQuery
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:
preparein interfaceQuery- Overrides:
preparein classSqlFileBatchModifyQuery<ELEMENT>
-
preInsert
protected void preInsert()Executes pre-insert entity lifecycle callbacks.This method delegates to the entity handler if one is available.
-
generateId
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:
generateIdin interfaceBatchInsertQuery- Parameters:
statement- the statement used for the batch operationindex- 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.
-
setEntityType
Sets the entity type for this query.This implementation creates an entity handler for the specified entity type.
- Specified by:
setEntityTypein classSqlFileBatchModifyQuery<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:
isBatchSupportedin interfaceBatchInsertQuery- Returns:
- true if batch operations are supported, false otherwise
-