complex aggregate nesting

What is the difference between

AbstractEventSourcedEntity or AbstractAnnotatedEntity

My interpretation is AbstractEventSourcedEntity is for event sourced aggregates and the other one is not?

Also, can any of these classes have nested aggregates of these types in a composition hierarchy and would event handling work same way it does with aggregate root?

Thanks and Cheers…


the AbstractAnnotatedEntity extends AbstractEventSourcedEntity. Similar to the AggregateRoot structure, the latter provides annotation support for the EventHandler methods, insead of expecting you to implement a handle() method.

You can nest these Entity instances as deep as you like. Each applied event will always be first appllied to the aggregate root, and is then propagated down the hierarchy.
Beware of terminology, by the way: you cannot nest aggregates. Entities are “nested” into aggregates, in which one entity is the aggregate root. The latter has a special class in Axon (AbstractAnnotatedAggregateRoot). All the other entities may extends AbstractAnnotatedEntity.

Hope that answers your question.


Thanks for the clarification… yes entity nest from one aggregate root…