Axon 0.6 deprecated Repository.load(UUID uuid) in favor of
Repository.load(UUID uuid, long version);

I have a practical question. When I look at the order example from the
jteam blog, this would mean that the OrderCommandHandler must pass the
expectedversion to the reporsitory handling the cancel and confirm


    public void confirmOrder(ConfirmOrderCommand command) {

        Order order = orderRepository.load(new




    public void cancelOrder(CancelOrderCommand command) {

        Order order = orderRepository.load(new



My question is where the heck does it get the version from?
What is the meaning of the expectedVersion?


Hi Jaron,

the method has not been removed in 0.7 (and it’s not deprecated there either). The sequence number of the last domain event from an aggregate is the version number of an aggregate. But the fact that you asked this question made me add an explicit getter to the DomainEvent class (getAggregateVersion).

So that’s where you can get it from. In 0.6, you’ll just need to get the sequence number of the event.

The version number of an aggregate is used as an optimistic locking mechanism. With event sourced aggregates, these optimistic locks can also be used to distinguish between conflicting changes and changes that can be safely merged. See org.axonframework.eventsourcing.ConflictResolver