Hybrid JPA repository


Previous versions of axon used to have a HybridJpaRepository which allowed storing both state-based and event-sourced representation of said aggregate. I notice that it disappeared during a merge in version 3.x . Is this a conscious decision?


Hi Prem,

it was indeed a conscious decision. Since Axon 3, the Event Store is a specialization of the Event Bus. Therefore, there is no difference between publishing an event and storing it.

To get the hybrid solution in Axon 3\4, simply use a GenericJpaRepository and configure an event store. Axon will assign sequence numbers to all events from each aggregate when storing the events.

I’ve seen implementations at customers where they structured aggregates af they were event sourced, but then configured the aggregate to be state-stored at runtime. This gives some of the advantages of event sourcing (testing, some guarantee that all changes are reflected as events), but doesn’t have the ‘burden’ of maintauning large event streams (events can be deleted safely once considered ‘expired’).