protected function _beforeEntityUpdate(AnCommandContext $context)
    {
        if ($this->getModifiedData()->ordering) {
            $store = $this->getRepository()->getStore();
            $query = $this->getScopedQuery($context->entity);
            $change = $this->getModifiedData()->ordering;

            if ($change->new - $change->old < 0) {
                $query->update('@col(ordering) = @col(ordering) + 1');
                $query->where('ordering', '>=',  $change->new)->where('ordering', '<',   $change->old);
            } else {
                $query->update('@col(ordering) = @col(ordering) - 1');
                $query->where('ordering', '>',   $change->old)->where('ordering', '<=',  $change->new);
            }

            $store->execute($query);
        }
    }