Interface PostUpdateContext<E>

Type Parameters:
E - the entity type being updated
All Known Implementing Classes:
AbstractPostUpdateContext, AutoBatchUpdateQuery.AutoBatchPostUpdateContext, AutoUpdateQuery.AutoPostUpdateContext, SqlFileBatchUpdateQuery.SqlFileBatchPostUpdateContext, SqlFileUpdateQuery.SqlFilePostUpdateContext

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

This interface provides methods to check if an entity or its properties have changed since the last database read, as well as methods to access and modify the entity being updated. It is typically used in entity listener implementations to perform custom logic after an update operation.

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

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Doma configuration associated with this update operation.
    Returns the entity type metadata for the entity being updated.
    Returns the DAO method that is annotated with Update and triggered this update operation.
    Returns the entity instance that was updated.
    Returns the returning properties configuration for this update operation.
    boolean
    isPropertyChanged(String propertyName)
    Determines whether a specific property of the entity has been changed.
    void
    setNewEntity(E newEntity)
    Sets a new entity instance to be used after the update operation.
  • Method Details

    • isPropertyChanged

      boolean isPropertyChanged(String propertyName)
      Determines whether a specific property of the entity has been changed.

      This method checks if the specified property has been modified by comparing its current value with the original value stored in the OriginalStates field.

      This method always returns true when Update.sqlFile() returns true, as SQL file-based updates do not perform change detection.

      Parameters:
      propertyName - the name of the property to check
      Returns:
      true if the property has been changed, false otherwise
      Throws:
      EntityPropertyNotDefinedException - if the property is not defined in the entity
      See Also:
    • getEntityType

      EntityType<E> getEntityType()
      Returns the entity type metadata for the entity being updated.

      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 Update and triggered this update operation.

      This method provides access to the reflection Method object representing the DAO method that initiated the update operation.

      Returns:
      the Method object representing the DAO method
    • getConfig

      Config getConfig()
      Returns the Doma configuration associated with this update 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 updated.

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

      Returns:
      the updated entity instance
    • setNewEntity

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

      This method is primarily used with immutable entity classes, allowing entity listeners to replace the entity instance with a modified version.

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

      default ReturningProperties getReturningProperties()
      Returns the returning properties configuration for this update operation.

      Returning properties specify which columns should be returned by the database after an update operation, typically used with the RETURNING clause in SQL.

      Returns:
      the returning properties configuration, never null
      See Also: