AbstractAggregateRoot fields not transient


Is there a reason the eventContainer, deleted, lastEventSequenceNumber and version fields are not marked as “transient” ?

The first two fields are annotated with @Transient but not marked transient per se.

Thank you,

Hi Nicolas,

the reason is two types of serialization that could be in play. The first is persistence after the aggregate has been committed. If the aggregate is stored relationally in a db (i.e. not event sourced), the @Transient fields do not need to be stored. This information can be deducted from other fields when it is deserialized.

However, when an aggregate is serialized (e.g. using java serialization) without being committed, you’d probably expect the exact same state as when it was serialized. That’s why the fields can’t be transient.

Originally, I planned to make the fields transient and document the fact that uncommitted events would not be part of the serialization of an aggregate. However, since this is a backwards incompatible change, I’ve decided to postpone it.

Just curious, is this in they way somehow?



Hi Allard,

I’m trying to marshall the aggregate with Jackson to store the snapshots. Jackson tries to serialize the non-transient fields and fails because it doesn’t know how to serialize/unserialize them.

What would you suggest to marshall an aggregate to JSON for snapshot storage ?

Thank you

Hi Nicholas,

if it is for snapshots, you can safely skip the @Transient annotated fields when serializing. Since the aggregate may be assumed to be in the “committed” state, there is no valuable information in those fields.