Identifier not aligned in generated tables: `user` and `domain_event_entry`

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?

Hi Orvyl,

I’m a bit confused by the extends AbstractAggregateRoot. (In Axon 3, all you need is the @Aggregate annotation)
The AbstractAggregateRoot is probably a Spring Data class, unrelated to Axon. By the look of it it is using domainevents too, so there might be your issue.

You could try without the extends to see what it brings you.

Frank

I removed the extends AbstractAggregateRoot but same result. I think my problem is related with [GenericJpaRepository and EventStore at the same time]. What I want to happen is the userId of a domain(user) should be used also as the aggregate_identifier of every event persisted in the domain_event_entry. I’ll explore more. Thank you Frank.

Hi,

this ‘issue’ is due to the fact that you aggregate is not event sourced (you’re using a repository that stores and loads based on state). Therefore, the events you produce are EventMessages, not DomainEventMessages. To allow these events to be stored in the Event Store, however, combination of ‘aggregateIdentifier’ (for which StreamId would have been a better name) and sequenceNumber needs to be unique. To do so, the ‘aggregateIdentifier’ for these messages is set to the messageId.

So it’s actually normal for these values to appear random.

Cheers,

Allard