Store both Aggregate state and events


I am currently working on a pet project and I would like to store both the aggregate state and events generated by the aggregate. Would annotating the aggregate with the @Entity annotation and supplying @EventSourceHandler methods produce the result needed?


Hi @Faithman_Nartey, let me help you on that.

Since you are talking about storing the Aggregate State, that automatically leads me to talk about State Stored Aggregates which is a different pattern than Event Sourcing.

In that case, @EventSourcingHandlers should be used only when you are doing Event Sourcing, which means you are ‘always’ constructing the state of your aggregate based on past events and not storing the state of it.

About the @Entity annotation you mentioned, you can check the link I shared and you will get more knowledge about that together with examples.

Lucas Campos

Thank you @lfgcampos for the clarification.

Best regards,