Same aggregate Identifier for a different aggregate Type

I have the two below aggregates they share the same context, is it possible to obtain the same aggregate Identifier for a different aggregate Type ?


@Aggregate
@Getter
@Setter
@NoArgsConstructor
public class User {

    @AggregateIdentifier
    private String userId;

    @CommandHandler
    @CreationPolicy(AggregateCreationPolicy.ALWAYS)
    private void handle(InitializeUsers cmd) {
        AggregateLifecycle.apply(UsersInitialized.builder()
                .userId(cmd.getUserId())
                .users(cmd.getUsers())
                .build());
    }

    @EventSourcingHandler
    private void on(UsersInitialized evt) {
        this.userId = evt.getUserId();
    }
	
}

@Aggregate
@Getter
@Setter
@NoArgsConstructor
public class Cpam {

    @AggregateIdentifier
    private String userId;

    @CommandHandler
    @CreationPolicy(AggregateCreationPolicy.ALWAYS)
    private void handle(InitializeCpams cmd) {
        AggregateLifecycle.apply(CapmsInitialized.builder()
                .userId(cmd.getUserId())
                .capms(cmd.getCapms())
                .build());
    }

    @EventSourcingHandler
    private void on(CapmsInitialized evt) {
        this.userId = evt.getUserId();
    }
	
}

An aggregate identifier has to be unique in a context. Maybe the proper way to model this, is using an aggregate member.

What Gerard says holds.
The EventStore expects a unique aggregateIdentifier, regardless of the type.

You can wrap the aggregate type in there yourself if you like, though.
If instead of a String, you make a UserId and CpamId, you could resolve this.
Axon Framework always invokes the toString() operation on the @AggregateIdentifier annotated field/getter. Thus, if you override the toString() method of said identifier objects, you can add the type in there yourself.

However, whether you actually want this yes/no as another point.
Perhaps you can share with us why you want to reuse the (intended unique) aggregate identifier among different domain models?