[axonframework] Get the instance of an AR outside the AR

Hi Sean,

strictly speaking, when using CQRS, you should never query an aggregate for its state. If you have a need for information, you’d always use the query models for that. Needing to query your aggregates is considered a “design smell” and generally means that there is something wrong in the model.

There are definitely cases where you want a command model to keep a certain state, for example when using set-validation. A common example is validating for unique usernames when creating an account. In that case, you’ll build a “query model” (although strictly speaking it’s just a “registry” of some sort within your command model) that is kept in a consistent state with your aggregate. An incoming command would first put the claimed username in the table, and then create the rest of the user account. If adding the name fails, the command for creating the account fails.

Hope this helps.