public function contains($entity)
    {
        return $this->unitOfWork->isScheduledForInsert($entity)
            || ($this->unitOfWork->isInIdentityMap($entity) && ! $this->unitOfWork->isScheduledForDelete($entity));
    }