Skip to content

Commit

Permalink
Define some Aggregate specific annotations their scope changed
Browse files Browse the repository at this point in the history
The first mentions of the @AggregateIdentifier, @EntityID and
@AggregateMember annotations should define these can be placed both on a
 field and on a method

#framework-4.4-update
  • Loading branch information
smcvb committed Aug 4, 2020
1 parent 902a328 commit 35ef911
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class GiftCard {
There are a couple of noteworthy concepts from the given code snippets, marked with numbered Java comments referring to the following bullets:

1. The `@AggregateIdentifier` is the external reference point to into the `GiftCard` Aggregate.

This field is a hard requirement, as without it Axon will not know to which Aggregate a given Command is targeted.
Note that this annotation can be placed on a field and a method.

2. A `@CommandHandler` annotated constructor, or differently put the 'command handling constructor'.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,18 @@ public class GiftCardTransaction {
Entities are, just like the aggregate root, simple objects, as is shown with the new `GiftCardTransaction` entity. The snippet above shows two important concepts of multi-entity aggregates:

1. The field that declares the child entity/entities must be annotated with `@AggregateMember`.

This annotation tells Axon that the annotated field contains a class that should be inspected for message handlers.

This example shows the annotation on an implementation of `Iterable`, but it can also be placed on a single Object or a `Map`.

In the latter case, the values of the `Map` are expected to contain the entities, while the key contains a value that is used as their reference.
Note that this annotation can be placed on a field and a method.

2. The `@EntityId` annotation specifying the identifying field of an Entity.

Required to be able to route a command \(or [event](multi-entity-aggregates.md#event-sourcing-handlers-in-entities)\) message to the correct entity instance.

The property on the payload that will be used to find the entity that the message should be routed to, defaults to the name of the `@EntityId` annotated field.

For example, when annotating the field `transactionId`, the command must define a property with that same name, which means either a `transactionId` or a `getTransactionId()` method must be present.

If the name of the field and the routing property differ, you may provide a value explicitly using `@EntityId(routingKey = "customRoutingProperty")`.

This annotation is **mandatory** on the Entity implementation if it will be part of a `Collection` or `Map` of child entities.
Note that this annotation can be placed on a field and a method.

> **Defining the Entity type**
>
Expand Down

0 comments on commit 35ef911

Please sign in to comment.