Hi Allard,
Thank you for your response.
An aggregate should never directly reference any entity outside of that
aggregate. The only type of reference allowed is by identifier.
So we'd better reference only the Customer ID instead of Customer
entity.
But, this does not apply to Order -> Order Items does it ? Since we
can only add Order Items through Order ?
If an activity in one aggregate should result in a modification of another,
you should ask yourself this question first: aren't these supposed to be
inside the same aggregate? The answer to that question depends on the
consistency requirements that these changes have.
If they are really two separate aggregates, you should create an Event
Listener or better, a Saga (but it's under development in Axon 0.7) that
picks up that event and sends out a command to update the other aggregate.
My question, what's the difference between the upcoming Saga and the
mechanism we have so far ?
In you case, the customer details in the Order probably have to be updated
when a customer has been updated. But that makes me wonder: the customer
inside an order, is that really identical to the stand-alone customer?
Typically, when an order is confirmed, data remains unchanged. If you change
a Customer's address, that won't automatically change the Order's address.
The problem you're facing could be a sign that something is wrong in the
design of your model.
Cheers,
Allard
Thanks & Regards,
Setya