- Type Parameters:
E- the entity type being inserted
- All Known Implementing Classes:
AbstractPreInsertContext,AutoBatchInsertQuery.AutoBatchPreInsertContext,AutoInsertQuery.AutoPreInsertContext,AutoMultiInsertQuery.AutoPreInsertContext,SqlFileBatchInsertQuery.SqlFileBatchPreInsertContext,SqlFileInsertQuery.SqlFilePreInsertContext
This interface provides methods to access and modify the entity being inserted, as well as methods to access configuration and metadata about the insert operation. It is typically used in entity listener implementations to perform custom logic before an insert operation.
The context is passed to the preInsert method of entity listeners.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the Doma configuration associated with this insert operation.Returns the duplicate key handling strategy for this insert operation.Returns the entity type metadata for the entity being inserted.Returns the DAO method that is annotated withInsertand triggered this insert operation.Returns the entity instance that is about to be inserted.default ReturningPropertiesReturns the returning properties configuration for this insert operation.voidsetNewEntity(E newEntity) Sets a new entity instance to be used for the insert operation.
-
Method Details
-
getEntityType
EntityType<E> getEntityType()Returns the entity type metadata for the entity being inserted.The entity type provides access to metadata about the entity class, including its properties, naming conventions, and other configuration.
- Returns:
- the entity type metadata
-
getMethod
Method getMethod()Returns the DAO method that is annotated withInsertand triggered this insert operation.This method provides access to the reflection Method object representing the DAO method that initiated the insert operation.
- Returns:
- the Method object representing the DAO method
-
getConfig
Config getConfig()Returns the Doma configuration associated with this insert operation.The configuration provides access to database connection, dialect, and other runtime settings for the current operation.
- Returns:
- the Doma configuration
-
getNewEntity
E getNewEntity()Returns the entity instance that is about to be inserted.This is the entity instance before any modifications made by entity listeners in their preInsert methods.
- Returns:
- the entity instance to be inserted
-
setNewEntity
Sets a new entity instance to be used for the insert operation.This method is primarily used with immutable entity classes, allowing entity listeners to replace the entity instance with a modified version before it is inserted into the database.
- Parameters:
newEntity- the new entity instance to use- Throws:
DomaNullPointerException- ifnewEntityisnull
-
getDuplicateKeyType
DuplicateKeyType getDuplicateKeyType()Returns the duplicate key handling strategy for this insert operation.This method indicates how the insert operation should handle duplicate key violations, such as by updating the existing record, ignoring the error, or throwing an exception.
- Returns:
- the duplicate key handling strategy
- See Also:
-
getReturningProperties
Returns the returning properties configuration for this insert operation.Returning properties specify which columns should be returned by the database after an insert operation, typically used with the RETURNING clause in SQL.
- Returns:
- the returning properties configuration, never
null - See Also:
-