- All Implemented Interfaces:
InsertQuery,ModifyQuery,Query
This class extends SqlFileModifyQuery to provide functionality for executing INSERT
statements defined in external SQL files. It handles entity lifecycle callbacks and SQL file
execution.
-
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 SqlFileInsertQuery.EntityHandler<?>The entity handler for this query.protected booleanWhether to exclude null properties from the insert operation.Fields inherited from class org.seasar.doma.jdbc.query.SqlFileModifyQuery
EMPTY_STRINGS, excludedPropertyNames, executable, includedPropertyNames, kind, optimisticLockCheckRequired, parameters, sql, sqlExecutionSkipCause, sqlFilePath, sqlLogTypeFields inherited from class org.seasar.doma.jdbc.query.AbstractQuery
callerClassName, callerMethodName, config, message, method, queryTimeout -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Completes this query after execution.voidgenerateId(Statement statement) Generates an ID for the inserted row.<E> EReturns the entity associated with this query.protected voidExecutes pre-insert entity lifecycle callbacks.voidprepare()Prepares this query for execution.protected voidPrepares the executable state for this query.<E> voidsetEntityAndEntityType(String name, E entity, EntityType<E> entityType) Sets the entity and entity type for this query.voidsetNullExcluded(boolean nullExcluded) Sets whether to exclude null properties from the insert operation.Methods inherited from class org.seasar.doma.jdbc.query.SqlFileModifyQuery
addParameter, addParameterInternal, expandColumns, getSql, getSqlExecutionSkipCause, getSqlLogType, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequired, populateValues, prepareOptions, prepareSql, setExcludedPropertyNames, setIncludedPropertyNames, setSqlFilePath, setSqlLogType, toStringMethods inherited from class org.seasar.doma.jdbc.query.AbstractQuery
comment, getClassName, getConfig, 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.ModifyQuery
getSql, getSqlExecutionSkipCause, getSqlLogType, isAutoGeneratedKeysSupported, isExecutable, isOptimisticLockCheckRequiredMethods inherited from interface org.seasar.doma.jdbc.query.Query
comment, getClassName, getConfig, getMethod, getMethodName, getQueryTimeout
-
Field Details
-
nullExcluded
protected boolean nullExcludedWhether to exclude null properties from the insert operation. -
entityHandler
The entity handler for this query.
-
-
Constructor Details
-
SqlFileInsertQuery
public SqlFileInsertQuery()Constructs a new instance.This constructor initializes the query with
SqlKind.INSERTto indicate that it performs an INSERT 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.
- Specified by:
preparein interfaceQuery- Overrides:
preparein classAbstractQuery
-
preInsert
protected void preInsert()Executes pre-insert entity lifecycle callbacks.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.
-
generateId
Generates an ID for the inserted row.This method is called after executing the INSERT statement to retrieve and set auto-generated keys or sequence values for the entity. It's typically used for primary key generation strategies like identity columns or sequences.
This implementation does nothing because this query does not support auto-generated keys.
- Specified by:
generateIdin interfaceInsertQuery- Parameters:
statement- the statement used for the INSERT operation
-
getEntity
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
-
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.
-
setEntityAndEntityType
Sets the entity and entity type for this query.This implementation creates an entity handler for the specified entity.
- Specified by:
setEntityAndEntityTypein classSqlFileModifyQuery- Type Parameters:
E- the entity type- Parameters:
name- the parameter name for the entityentity- the entityentityType- the entity type
-
setNullExcluded
public void setNullExcluded(boolean nullExcluded) Sets whether to exclude null properties from the insert operation.- Parameters:
nullExcluded- whether to exclude null properties
-