Annotation Interface TransactionAware


@Documented @Inherited @Retention(RUNTIME) @Target(TYPE) public @interface TransactionAware
Used to annotate events which need to be aware of the surrounding transaction, if any.

The primary use case for this annotation is events which are raised when a persistent entity is updated in some way. Such events may be raised while the transaction to update the entity is still in progress, but should only be published when the transaction is committed.

If a TransactionAware event is raised while no transaction is in progress, it is always published immediately regardless of the configuration applied by this annotation.

This setting is inherited. If a derived event does not need to be transaction aware, it may be annotated with: @TransactionAware(TransactionAware.When.IMMEDIATE) Such configuration indicates the event should be published immediately when it is raised, which is the same behaviour that is applied if this annotation is not present on the event's class.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Defines the different points, relative to a transaction's lifecycle, at which an event can be published.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Configures when the event should be dispatched, relative to the transaction lifecycle.
  • Element Details

    • value

      Configures when the event should be dispatched, relative to the transaction lifecycle.

      By default, the event will be dispatched after the transaction is committed. This means if the transaction does not commit, the event will not be published.

      Returns:
      the point in the transaction lifecycle at which the event should be published
      See Also:
      Default:
      AFTER_COMMIT