aggregate look up using attribute of and aggregate ,but not the GUID or AggregateRootID

Hi
Is it possible to lookup and aggregate using attributes of a aggregate
root in axon framework.

The example showing in axon-addressbook-app-0.5-sources

Has the following code and it does not work and it throws
java.lang.RuntimeException: java.lang.IllegalArgumentException:
Invalid UUID string: steve

Contact contact =
repository.load(UUID.fromString(command.getContactNewName()));

found in
ContactCommandHandler

@CommandHandler
    public void handle(ChangeContactNameCommand command) {
        Assert.notNull(command.getContactId(), "ContactIdentifier may
not be null");
        Assert.notNull(command.getContactNewName(), "Name may not be
null");
        Contact contact =
repository.load(UUID.fromString(command.getContactNewName()));
        contact.changeName(command.getContactNewName());
        repository.save(contact);
    }

test case written

// insert a contact
SampleCallBackHandler<CreateContactCommand,UUID>
sampleCallBackHandler=new
SampleCallBackHandler<CreateContactCommand,UUID>();
CreateContactCommand createContactCommand =new CreateContactCommand();
createContactCommand.setNewContactName("steve");

commandBus.dispatch(createContactCommand ,sampleCallBackHandler);

assertNotNull(sampleCallBackHandler.getResult());

//change the contact
SampleCallBackHandler<ChangeContactNameCommand,Object>
sampleCallBackHandler1=new
SampleCallBackHandler<ChangeContactNameCommand,Object>();
    ChangeContactNameCommand changeContactNameCommand =new
ChangeContactNameCommand();
    changeContactNameCommand.setContactId("1");
    changeContactNameCommand.setContactNewName("steve");
  
commandBus.dispatch(changeContactNameCommand ,sampleCallBackHandler1);

Hi Steve,

that was a bug in the 0.5 version. It has been fixed in the 0.6 version, but wasn’t merged back. You might want to take a look at the 0.6 version of the sample. It is more up-to-date with progress made in the Framework.

But to answer your question: No, it is not possible to load an aggregate (in the command model) based on any other information than its Identifier. The only “legal” way to do that is do a query to get the ID, and use that ID on the aggregate’s repository.

Cheers,

Allard