Aggregate: Testing the uniqueness of a field

In this example of an aggregate, I would like to test if an aggregate already exists with a given email, before creating a new aggregate: How to do this?
Is there some sort of AggregateRepository (like JpaRepository) interface that I can extend with a CustomerAggregateRepository Interface that will allow me to check if this email already exists?

NB: I am a junior with Axon
@Aggregate
public class CustomerAggregate {

@AggregateIdentifier
private String customerId;
private String email; // must be unique
private String firstname.

}

Hi @BrodyGaudel
Have you already seen this blog article?
Maybe it will help you.

1 Like