FOSUserBundle User addGroup does not save in the database
<p>I am trying to add users to role groups but for some reason I cannot achieve this.
I followed the documentation on symfony website <a href="http://symfony.com/doc/current/bundles/FOSUserBundle/groups.html" rel="nofollow">http://symfony.com/doc/current/bundles/FOSUserBundle/groups.html</a>. The object is created and it's correct but on flush nothing happens.</p>

<p>UserRoleGroups are already defined in the DB.</p>

<blockquote>
  <p>saving </p>
</blockquote>

<pre><code>$oGroup = $this-&gt;em-&gt;getRepository('UserBundle:UserRoleGroups')-&gt;findOneByName($sRole);

$oUser-&gt;addGroup($oGroup);
$this-&gt;em-&gt;persist($oUser);
$this-&gt;em-&gt;flush();
</code></pre>

<p>Any other changes I do to $oUser object are saved except for this one.</p>

<blockquote>
  <p>User Entity</p>
</blockquote>

<pre><code>class User extends BaseUser
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToMany(
     *     targetEntity="App\UserBundle\Entity\UserRoleGroups"
     * )
     * @ORM\JoinTable(
     *     name="users_user_role_group",
     *     joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
     * )
     */
    protected $userRolesGroup;
</code></pre>

<blockquote>
  <p>UserRoleGroup Entity</p>
</blockquote>

<pre><code>class UserRoleGroups extends BaseGroup
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
</code></pre>