[AXONIQ-2000] Invalid sequence number 0 for aggregate


I am new in Axon and I need help.
I faced with the problem.
I am trying to develop CRUD for one Entity.
Now I have developed aggreate.

class UpdatePermission() {
private var id: AxxalonIdentifier? = null

constructor(command: UpdatePermissionCommand) : this() {
var a = AggregateLifecycle.apply(PermissionUpdateEvent(command.id, command.title))

constructor(command: CreatePermissionCommand) : this() {
var a = AggregateLifecycle.apply(PermissionCreatedEvent(command.id, command.title))


@EventSourcingHandler(payloadType = PermissionUpdateEvent::class)
fun on(event: PermissionUpdateEvent) {
this.id = event.id

@EventSourcingHandler(payloadType = PermissionCreatedEvent::class)
fun on(event: PermissionCreatedEvent) {
this.id = event.id

And I have the problem with the aggregate.

What is wrong? Do I need a saga for create/update/delete entity by command and event?
Thank you very much for advice!

Hi Sergey,

your command handler for UpdatePermissionCommand is (also) a constructor. That tells Axon that, for this command, you want to create a new instance. However, given the name, I suspect you want to update an existing one.

Change that method to a ‘fun’, and it should work.