Merge pull request #13719 from FabioBentoLuiz/fix/es-userutility

Event Sourcing - Recreate user with id from the UserCreatedEvent instead of creating a new one
This commit is contained in:
Kasra Madadipouya 2023-05-24 23:16:59 +02:00 committed by GitHub
commit 75da1d17c6
1 changed files with 1 additions and 2 deletions

View File

@ -23,8 +23,7 @@ public class UserUtility {
for (Event event : events) { for (Event event : events) {
if (event instanceof UserCreatedEvent) { if (event instanceof UserCreatedEvent) {
UserCreatedEvent e = (UserCreatedEvent) event; UserCreatedEvent e = (UserCreatedEvent) event;
user = new User(UUID.randomUUID() user = new User(e.getUserId(), e.getFirstName(), e.getLastName());
.toString(), e.getFirstName(), e.getLastName());
} }
if (event instanceof UserAddressAddedEvent) { if (event instanceof UserAddressAddedEvent) {
UserAddressAddedEvent e = (UserAddressAddedEvent) event; UserAddressAddedEvent e = (UserAddressAddedEvent) event;