I’m new with axon and currently using AxonFramework 3.0.4 and Spring Boot.
I have an aggregate User and command CreateUserCommand:
`
@Aggregate(repository = “myRepository”)
@Entity
@Data //lombok
@NoArgsConstructor
public class User extends AbstractAggregateRoot {
@Id
private String userId;
private String completeName;
@CommandHandler
public User(CreateUserCommand cmd) {
apply(new UserCreatedEvent(cmd.getUserId(), cmd.getCompleteName()));
}
@EventSourcingHandler
public void on(UserCreatedEvent event) {
this.userId = event.getUserId();
this.completeName = event.getCompleteName;
}
}
//from another file
@Data
public class CreateUserCommand {
@TargetAggregateIdentifier
private String userId;
private String completeName;
public CreateUserCommand() {}
public CreateUserCommand(String userId, String completeName) {
this.userId = userId;
this.completeName = completeName;
}
}
//in my controller, i have this code
…
commandGateway.send(new CreateUserCommand(“user_123”, “Juan Miguel”));
…
`
With this, spring boot + axonFramework will auto generate tables and 2 of those are user and domain_event_entry.
After a successful create user transaction, what I’m expecting is the userId in user table is equal with the aggregate_identifier of every event under that same user, but it’s not. Instead, the expected userId is only used/saved in user table but a random UUID is saved under aggregate_identifier. Am I missing something?