Symfony2/3 Children Entity Constraint Assert ignored
<p>I have a situation where the validation constraints inside the entity classes are ignored...</p>

<p>This one does not work (which is a children of ActivityField Entity):</p>

<pre><code>&lt;?php
namespace XXX\ActivityFieldsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use XXX\DatabaseBundle\Entity\AbstractEntity;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity(repositoryClass="XXX\ActivityFieldsBundle\Repository\ActivityFieldLanguagesRepository")
 * @ORM\HasLifecycleCallbacks
 * @ORM\Table(name="activity_field_languages")
 */
class ActivityFieldLanguages extends AbstractEntity
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="name", type="text")
     * @Assert\NotBlank()    ----&gt; !!! this one here !!!
     */
    protected $name;
</code></pre>

<p>while this one (which is standalone does not have any connection to other entities) works:</p>

<pre><code>&lt;?php

namespace XXX\LanguagesBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use XXX\DatabaseBundle\Entity\AbstractEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use XXX\CommonBundle\Validator\Constraints as SiteAssert;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity(repositoryClass="XXX\LanguagesBundle\Repository\LanguagesRepository")
 * @ORM\HasLifecycleCallbacks
 * @ORM\Table(name="languages")
 *
 * @UniqueEntity(fields="name")
 * @UniqueEntity(fields="iso")
 */
class Languages extends AbstractEntity
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="name", type="string", unique=true)
     * @Assert\NotBlank() -----&gt; this one here !!!
     * @Assert\Length(
     *     min=2,
     *     minMessage="validator.minimum.2.characters"
     * )
     */
    protected $name;
</code></pre>

<p>If i add the constraint in FormType then all is ok and working but I don't want to have that and keep everything in the Entity file as annotation.
In my config file i have </p>

<pre><code>framework:
    validation:      { enable_annotations: true }
</code></pre>