Interface PostInsertContext<E>

Type Parameters:
E - the entity type that was inserted
All Known Implementing Classes:
AbstractPostInsertContext, AutoBatchInsertQuery.AutoBatchPostInsertContext, AutoInsertQuery.AutoPostInsertContext, AutoMultiInsertQuery.AutoPostInsertContext, SqlFileBatchInsertQuery.SqlFileBatchPostInsertContext, SqlFileInsertQuery.SqlFilePostInsertContext

public interface PostInsertContext<E>
A context for post-processing an entity after an insert operation.

This interface provides methods to access and modify the entity that was 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 after an insert operation.

The context is passed to the postInsert method of entity listeners.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Doma configuration associated with this insert operation.
    Returns the duplicate key handling strategy used for this insert operation.
    Returns the entity type metadata for the entity that was inserted.
    Returns the DAO method that is annotated with Insert and triggered this insert operation.
    Returns the entity instance that was inserted.
    Returns the returning properties configuration for this insert operation.
    void
    setNewEntity(E newEntity)
    Sets a new entity instance to be used after the insert operation.
  • Method Details

    • getEntityType

      EntityType<E> getEntityType()
      Returns the entity type metadata for the entity that was 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 with Insert and 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 was inserted.

      This is the entity instance after the insert operation and any modifications made by entity listeners in their postInsert methods.

      Returns:
      the inserted entity instance
    • setNewEntity

      void setNewEntity(E newEntity)
      Sets a new entity instance to be used after the insert operation.

      This method is primarily used with immutable entity classes, allowing entity listeners to replace the entity instance with a modified version after it has been inserted into the database.

      Parameters:
      newEntity - the new entity instance to use
      Throws:
      DomaNullPointerException - if newEntity is null
    • getDuplicateKeyType

      DuplicateKeyType getDuplicateKeyType()
      Returns the duplicate key handling strategy used for this insert operation.

      This method indicates how the insert operation handled 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

      default ReturningProperties 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: