Doctrine:Update won't update all properties

This is my Category class. When I use doctrine:update properties childrens, tracks and parent are not created in the database… other properties are created.

/**
* One Category has Many Categories.
* @ORM\OneToMany(mappedBy=“parent”)
* @ORM\OrderBy({“name” = “ASC”})
* @var Collection
*/
private $childrens;

/**
* @return Collection
*/
public function getChildrens() {
        return $this->childrens;
}

/**
* Adds a children to this Category
*
* @param Category $children
* @return void
*/
public function addChildren(Category $children) {
        $this->childrens->add($children);
}

/**
* Removes a children from this Category
*
* @param Category $children
* @return void
*/
public function removeChildren(Category $children) {
        $this->childrens->removeElement($children);
}


/**
 * Many Categories have One Category.
 * @ORM\ManyToOne(inversedBy="childrens")
 * @var Category
 */
private $parent;

/**
 * @return Category
 */
public function getParent()
{
    return $this->parent;
}

/**
 * @param Category $parent
 * @return void
 */
public function setParent(Category $parent)
{
    $this->parent = $parent;
    $parent->addChildren(this);
}

/**
 * One Category has Many Tracks.
 * @ORM\OneToMany(mappedBy="category")
 * @ORM\OrderBy({"file" = "ASC"})
 * @var Collection<Track>
 */
private $tracks;

/**
* @return Collection
*/
public function getTracks() {
        return $this->tracks;
}

/**
* Adds a track to this Category
*
* @param Track $track
* @return void
*/
public function addTrack(Track $track) {
        $this->tracks->add($track);
}

/**
* Removes a track from this Category
*
* @param Track $track
* @return void
*/
public function removeTrack(Track $track) {
        $this->tracks->removeElement($track);
}

Hey @Mehdi,

can you try to make the property protected instead of private ? It might be that when it is private, Doctrine cannot properly infer them.

I am not really sure on this; but that would be something to try out maybe first :upside_down_face: - maybe others have other good ideas? :slight_smile:

All the best,
Sebastian

1 Like

That was it. Thank you.

1 Like