Doctrine Extensions Sortable not working correctly when changing position by more than 1 : <p>Im using Symfony 3.1 + Doctrine GEDMO extensions (via StofDoctrineExtensionsBundle). I've set my entity to have Sortable behavior:</p>

<pre><code>&lt;?php

namespace AppBundle\Entity\Manual;

use AppBundle\Entity\Identifier;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Table(name="manual_pages")
 * @ORM\Entity(repositoryClass="Gedmo\Sortable\Entity\Repository\SortableRepository")
 */
class Manual
{
    use Identifier;

    /**
     * @ORM\Column(type="string")
     * @Assert\NotBlank(message="Toto pole musí být vyplněno")
     */
    private $title;

    /**
     * @ORM\Column(type="text")
     * @Assert\NotBlank(message="Toto pole musí být vyplněno")
     */
    private $content;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Manual\ManualImage", mappedBy="manual")
     * @ORM\OrderBy({"position"="ASC"})
     */
    private $images;

    /**
     * @Gedmo\SortablePosition
     * @ORM\Column(type="integer", nullable=false)
     */
    private $position;

    /**
     * @return mixed
     */
    public function getPosition()
    {
        return $this-&gt;position;
    }

    /**
     * @param mixed $position
     */
    public function setPosition($position)
    {
        $this-&gt;position = $position;
    }


    /**
     * @return mixed
     */
    public function getTitle()
    {
        return $this-&gt;title;
    }

    /**
     * @param mixed $title
     */
    public function setTitle($title)
    {
        $this-&gt;title = $title;
    }

    /**
     * @return ManualImage[]
     */
    public function getImages()
    {
        return $this-&gt;images;
    }

    /**
     * @param ManualImage[] $images
     */
    public function setImages($images)
    {
        $this-&gt;images = $images;
    }

    /**
     * @return mixed
     */
    public function getContent()
    {
        return $this-&gt;content;
    }

    /**
     * @param mixed $content
     */
    public function setContent($content)
    {
        $this-&gt;content = $content;
    }


}
</code></pre>

<p>When i proceed to change position by one the sorting behavior is acting OK:</p>

<pre><code>$entity-&gt;setPosition($entity-&gt;getPosition() + 1);
// or
$entity-&gt;setPosition($entity-&gt;getPosition() - 1);
</code></pre>

<p>But when I've implemented JS drag&amp;drop to change positions the whole thing gets weird. For example, having this table:</p>

<pre><code>id    | position
1     | 0
2     | 1
3     | 2
4     | 3
5     | 4
6     | 5
</code></pre>

<p>when I do for row with id 6 this:</p>

<pre><code>$newPosition = $entity-&gt;getPosition() - 5; // = 0
$entity-&gt;setPosition($newPosition);
</code></pre>

<p>the table changes to this:</p>

<pre><code>id    | position
1     | 2
2     | 3
3     | 4
4     | 5
5     | 5
6     | 0
</code></pre>

<p>There is nothing for position 1 but position 5 is occupied twice. Any ideas?</p>
