repository identifier

Hello,
I’d like to ask what was the decision to make the identifier string instead of object on org.axonframework.commandhandling.model.Repository?
In current project we have something like

public interface DomainIdentifier<T> {

   T getIdentifier();
}

and loading aggregates with it. I know that I can still use toString() method of my domainIdentifier but I’m just wondering.

What is the difference between org.axonframework.commandhandling.model.Aggregate#identifier() and the parameter aggregateIdentifier used here org.axonframework.commandhandling.model.Repository#load(String aggregateIdentifier)?

Thanks

Hi,

In Axon 2 your identifier was also converted to a string (using quite a convoluted process). In Axon 3 this was simplified to just using the toString() version of your identifier object.

Axon uses the string version of your identifier to select the aggregate’s events. Once it is converted to a string you should not look at the identifier as something belonging to your domain anymore but rather as something belonging to Axon’s domain (used to find events).

Anyway… Aggregate#identifier() returns your domain’s identifier which is then converted by Axon to a string (see Aggregate#identifierAsString()) to group your aggregate’s events. Repository#load(String aggregateIdentifier) uses that string as well (using the string version of your @TargetAggregateIdentifier annotated identifier parameter).

Hope that did not add to the confusion :wink: