private void detectIllegalStateChanges() {
if (aggregateIdentifier != null && workingAggregate != null && reportIllegalStateChange) {
UnitOfWork uow = DefaultUnitOfWork.startAndGet();
try {
EventSourcedAggregateRoot aggregate2 = repository.load(aggregateIdentifier);
if (workingAggregate.isDeleted()) {
throw new AxonAssertionError("The working aggregate was considered deleted, "
+ "but the Repository still contains a non-deleted copy of "
+ "the aggregate. Make sure the aggregate explicitly marks "
+ "itself as deleted in an EventHandler.");