title: Error Gedmo Tree extension : Root cannot be changed manually, change parent instead
body: <p>I tried to install and use the extension  Tree Gedmo with Category entity but when I add a new category I have this error:</p>
  
  <p><strong><em>Root cannot be changed manually, change parent instead</em></strong></p>
  
  <p>500 Internal Server Error - UnexpectedValueException.</p>
  
  <p>I have followed this link and I did everything as indicated: <a href="https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md" rel="nofollow">https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md</a></p>
  
  <p>I have created <strong>app/config/doctrine_extensions.yml</strong> and <strong>src/Project/StoreBundle/Listener/DoctrineExtensionListener.php</strong> also</p>
  
  <p><strong>app/conifg.yml</strong></p>
  
  <pre><code># Doctrine Configuration
  doctrine:
  dbal:
      driver:   "%database_driver%"
      host:     "%database_host%"
      port:     "%database_port%"
      dbname:   "%database_name%"
      user:     "%database_user%"
      password: "%database_password%"
      charset:  UTF8
      # if using pdo_sqlite as your database driver, add the path in parameters.yml
      # e.g. database_path: "%kernel.root_dir%/data/data.db3"
      # path:     "%database_path%"
  
  orm:
      auto_generate_proxy_classes: "%kernel.debug%"
      auto_mapping: true
      mappings:
          translatable:
              type: annotation
              alias: Gedmo
              prefix: Gedmo\Translatable\Entity
              # make sure vendor library location is correct
              dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
          loggable:
              type: annotation
              alias: Gedmo
              prefix: Gedmo\Loggable\Entity
              dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
          tree:
              type: annotation
              alias: Gedmo
              prefix: Gedmo\Tree\Entity
              dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
  
  //..........
  # Stof\DoctrineExtensionBundle configuration
  stof_doctrine_extensions:
      orm:
          default:
              sluggable: true
              tree: true
  </code></pre>
  
  <p><strong>Entity/Category.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace Project\StoreBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  
  use Gedmo\Mapping\Annotation as Gedmo; 
  use Doctrine\Common\Collections\ArrayCollection;
  use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  use Symfony\Component\Validator\Constraints as Assert;
  
  
  /**
  * Category
  * @Gedmo\Tree(type="nested")
  * @ORM\Table()
  * @ORM\Entity(repositoryClass="Project\StoreBundle\Entity\CategoryRepository")
  * @ORM\HasLifeCycleCallbacks()
  */
  class Category
  {
  /**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;
  
  /**
   * @var string
   *
   * @ORM\Column(name="name", type="string", length=255)
   *
   *@Assert\NotBlank(message="Please enter the name of category.")
   */
  private $name;
  
  /**
   * @Gedmo\slug(fields={"name"}, unique_base="uniqueBase")
   * @ORM\Column(name="slug",length=255, unique=false)
   */
  private $slug ;
  
  /**
   * @ORM\Column(name="uniqueBase", type="integer")
   */
  private $uniqueBase ;
  
  /**
   * @ORM\Column(name="description", type="text", nullable=true)
   */
  private $description;
  
  /**
   * @ORM\Column(name="metaDescription", type="string", length=255, nullable=true)
   *
   * @Assert\Length(
   *     max=255,
   *     maxMessage="message."
   *  )
   */
  private $metaDescription;
  
  /**
   * @ORM\Column(name="metaKeywords", type="string", length=255, nullable=true)
   *
   * @Assert\Length(
   *     max=255,
   *     maxMessage="message."
   *  )
   */
  private $metaKeywords;
  
  
  /**
   * @ORM\Column(name="enabled", type="boolean", nullable=false)
   */
  private $enabled;
  
  
  /**
   * @Gedmo\TreeLeft
   * @ORM\Column(name="lft", type="integer")
   */
  private $lft;
  
  /**
   * @Gedmo\TreeLevel
   * @ORM\Column(name="lvl", type="integer")
   */
  private $lvl;
  
  /**
   * @Gedmo\TreeRight
   * @ORM\Column(name="rgt", type="integer")
   */
  private $rgt;
  
  /**
   * @Gedmo\TreeRoot
   * @ORM\Column(name="root", type="integer", nullable=true)
   */
  private $root;
  
  /**
   * @Gedmo\TreeParent
   * @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
   * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
   */
  private $parent;
  
  /**
   * @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
   * @ORM\OrderBy({"lft" = "ASC"})
   */
  private $children;
  
  /**
   * @ORM\ManyToOne(targetEntity="Project\StoreBundle\Entity\Store", inversedBy="categories", cascade={"persist"})
   * @ORM\JoinColumn(nullable=false)
   */
  private $store ;
  
  
  /**
   * Constructor
   */
  public function __construct()
  {
      $this-&gt;children = new ArrayCollection();
  }
  
  
  /**
   * Get id
   *
   * @return integer 
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Set name
   *
   * @param string $name
   * @return Category
   */
  public function setName($name)
  {
      $this-&gt;name = $name;
  
      return $this;
  }
  
  /**
   * Get name
   *
   * @return string 
   */
  public function getName()
  {
      return $this-&gt;name;
  }
  
  /**
   * Set slug
   *
   * @param string $slug
   * @return Category
   */
  public function setSlug($slug)
  {
      $this-&gt;slug = $slug;
  
      return $this;
  }
  
  /**
   * Get slug
   *
   * @return string 
   */
  public function getSlug()
  {
      return $this-&gt;slug;
  }
  
  /**
   * Set uniqueBase
   *
   * @param integer $uniqueBase
   * @return Category
   */
  public function setUniqueBase($uniqueBase)
  {
      $this-&gt;uniqueBase = $uniqueBase;
  
      return $this;
  }
  
  /**
   * Get uniqueBase
   *
   * @return integer 
   */
  public function getUniqueBase()
  {
      return $this-&gt;uniqueBase;
  }
  
  /**
   * Set description
   *
   * @param string $description
   * @return Category
   */
  public function setDescription($description)
  {
      $this-&gt;description = $description;
  
      return $this;
  }
  
  /**
   * Get description
   *
   * @return string 
   */
  public function getDescription()
  {
      return $this-&gt;description;
  }
  
  /**
   * Set metaDescription
   *
   * @param string $metaDescription
   * @return Category
   */
  public function setMetaDescription($metaDescription)
  {
      $this-&gt;metaDescription = $metaDescription;
  
      return $this;
  }
  
  /**
   * Get metaDescription
   *
   * @return string 
   */
  public function getMetaDescription()
  {
      return $this-&gt;metaDescription;
  }
  
  /**
   * Set metaKeywords
   *
   * @param string $metaKeywords
   * @return Category
   */
  public function setMetaKeywords($metaKeywords)
  {
      $this-&gt;metaKeywords = $metaKeywords;
  
      return $this;
  }
  
  /**
   * Get metaKeywords
   *
   * @return string 
   */
  public function getMetaKeywords()
  {
      return $this-&gt;metaKeywords;
  }
  
  /**
   * Set enabled
   *
   * @param boolean $enabled
   * @return Category
   */
  public function setEnabled($enabled)
  {
      $this-&gt;enabled = $enabled;
  
      return $this;
  }
  
  /**
   * Get enabled
   *
   * @return boolean 
   */
  public function getEnabled()
  {
      return $this-&gt;enabled;
  }
  
  /**
   * Set parent
   *
   * @param \Project\StoreBundle\Entity\Category $parent
   * @return Category
   */
  public function setParent(\Project\StoreBundle\Entity\Category $parent = null)
  {
      $this-&gt;parent = $parent;
  
      return $this;
  }
  
  /**
   * Get parent
   *
   * @return \Project\StoreBundle\Entity\Category 
   */
  public function getParent()
  {
      return $this-&gt;parent;
  }
  
  /**
   * Set lft
   *
   * @param integer $lft
   * @return Category
   */
  public function setLft($lft)
  {
      $this-&gt;lft = $lft;
  
      return $this;
  }
  
  /**
   * Get lft
   *
   * @return integer 
   */
  public function getLft()
  {
      return $this-&gt;lft;
  }
  
  /**
   * Set lvl
   *
   * @param integer $lvl
   * @return Category
   */
  public function setLvl($lvl)
  {
      $this-&gt;lvl = $lvl;
  
      return $this;
  }
  
  /**
   * Get lvl
   *
   * @return integer 
   */
  public function getLvl()
  {
      return $this-&gt;lvl;
  }
  
  /**
   * Set rgt
   *
   * @param integer $rgt
   * @return Category
   */
  public function setRgt($rgt)
  {
      $this-&gt;rgt = $rgt;
  
      return $this;
  }
  
  /**
   * Get rgt
   *
   * @return integer 
   */
  public function getRgt()
  {
      return $this-&gt;rgt;
  }
  
  /**
   * Set root
   *
   * @param integer $root
   * @return Category
   */
  public function setRoot($root)
  {
      $this-&gt;root = $root;
  
      return $this;
  }
  
  /**
   * Get root
   *
   * @return integer 
   */
  public function getRoot()
  {
      return $this-&gt;root;
  }
  
  /**
   * Add children
   *
   * @param \Project\StoreBundle\Entity\Category $children
   * @return Category
   */
  public function addChild(\Project\StoreBundle\Entity\Category $children)
  {
      $this-&gt;children[] = $children;
  
      return $this;
  }
  
  /**
   * Remove children
   *
   * @param \Project\StoreBundle\Entity\Category $children
   */
  public function removeChild(\Project\StoreBundle\Entity\Category $children)
  {
      $this-&gt;children-&gt;removeElement($children);
  }
  
  /**
   * Get children
   *
   * @return \Doctrine\Common\Collections\Collection 
   */
  public function getChildren()
  {
      return $this-&gt;children;
  }
  
  
  /**
   * Set store
   *
   * @param \Project\StoreBundle\Entity\Store $store
   * @return Category
   */
  public function setStore(\Project\StoreBundle\Entity\Store $store = null)
  {
      $this-&gt;store = $store;
  
      return $this;
  }
  
  /**
   * Get store
   *
   * @return \Project\StoreBundle\Entity\Store 
   */
  public function getStore()
  {
      return $this-&gt;store;
  }
  
  }
  </code></pre>