Annotation Interface InjectEntity


@Target(PARAMETER) @Retention(RUNTIME) public @interface InjectEntity
Annotation to be placed on a parameter of a MessageHandler annotated method that should receive an entity loaded from the StateManager.

The parameter should be of the type of the entity to inject, or of a ManagedEntity with the generic of the entity to inject.

The idProperty attribute can be used to specify the property of the message payload that contains the identifier of the entity to inject. If not specified, the idResolver is used to resolve the identifier of the entity to inject.

Unless a specific idResolver is specified, the AnnotationBasedEntityIdResolver is used to resolve the entity id from the message. This is based on finding a TargetEntityId annotation on a field or accessor method of the message payload.

So, identifiers will be resolved in the following order:

  1. From the property specified in idProperty.
  2. From the idResolver.
  3. From the TargetEntityId annotation on the message payload.
Since:
5.0.0
Author:
Mitchell Herrijgers
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The property of the message payload that contains the identifier of the entity to inject.
    The EntityIdResolver to resolve the identifier of the entity to inject.
  • Element Details

    • idProperty

      String idProperty
      The property of the message payload that contains the identifier of the entity to inject. If not specified, the idResolver is used to resolve the identifier of the entity to inject.
      Returns:
      The property of the message payload that contains the identifier of the entity to inject.
      Default:
      ""
    • idResolver

      Class<? extends EntityIdResolver> idResolver
      The EntityIdResolver to resolve the identifier of the entity to inject. Should have a no-arg constructor.
      Returns:
      The EntityIdResolver to resolve the identifier of the entity to inject.
      Default:
      org.axonframework.modelling.annotation.AnnotationBasedEntityIdResolver.class