I currently stumbled into the following problem: How do I enhance
events with data from references?
- Aggregate "A" has two fields: UUID + Name
- Aggregate "B" has a reference to "A" (it contains a fields with the
UUID of "A")
Now when deleteing "B" I want to have an event that contains also the
name of "A" in it's "toString()" message (Something like "B was
deleted from A").
The workflow would be as follows:
1) handle(DeleteBCommand command)
2) b = repository.load(idOfBToDelete)
4) apply(new BDeletedEvent(nameOfA))
But where do I get the "nameOfA" from as I only have the UUID of A
inside the B aggregate?
Now I have two options:
1) Enhance the "delete" method of B: "delete(String nameOfA)" - Seems
to be artificial to me
2) Load the name of A inside the "delete()" method - Requires using a
query service inside the aggregate
What would you prefer?