Class EntityMissingAfterLoadOrCreateException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.axonframework.eventsourcing.EntityMissingAfterLoadOrCreateException
All Implemented Interfaces:
Serializable

public class EntityMissingAfterLoadOrCreateException extends RuntimeException
Exception thrown by the EventSourcedEntityFactory when the entity returned by
invalid reference
EventSourcedEntityFactory#create(Object, EventMessage)
is null when calling it with a null firstEventMessage during the EventSourcingRepository.loadOrCreate(Object, ProcessingContext).

This indicates that the factory is incapable of creating an entity without an event message, as is the case with entities that only have a constructor that takes an event message or its payload. If this is the case, the EventSourcingRepository.load(Object, ProcessingContext) should be used instead, which will leave the entity as null if no events are found.

If the entity has a constructor that takes no arguments or an identifier, the factory should be adjusted to return a non-null entity when no event message is present.

Since:
5.0.0
Author:
Mitchell Herrijgers
See Also:
  • Constructor Details

    • EntityMissingAfterLoadOrCreateException

      public EntityMissingAfterLoadOrCreateException(Object identifier)
      Constructs the exception with the given identifier.
      Parameters:
      identifier - The identifier of the entity that was attempted to be loaded or created.