title: Doctrine 2 ManyToMany cascade
body: <p>Is it possible in Doctrine 2 to create two objects that are many to many related and call persist only on one of them to save both?</p>
  
  <p>User entity:</p>
  
  <pre><code>    /**
   * Owning Side
   *
   * @ManyToMany(targetEntity="Role", inversedBy="users", cascade={"persist"})
   * @JoinTable(name="user_roles",
   *      joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
   *      inverseJoinColumns={@JoinColumn(name="role_id", referencedColumnName="id")}
   *      )
   */
  public $roles;
  </code></pre>
  
  <p>Role entity:</p>
  
  <pre><code>    /**
   * Inverse Side
   *
   * @ManyToMany(targetEntity="User", mappedBy="roles")
   */
  public $users;
  </code></pre>
  
  <p>Saving:</p>
  
  <pre><code>    $role = new Role();
  
      $user = new User();
  
  $user-&gt;roles-&gt;add($role);
  $role-&gt;users-&gt;add($user);
  
  $em-&gt;persist($user);
  $em-&gt;flush();
  </code></pre>
  
  <p>It doesn't work and trows an error "A new entity was found through a relationship that was not configured to cascade persist operations: Entities\Role@0000000004a29c11000000005c48cb75. Explicitly persist the new entity or configure cascading persist operations on the relationship."</p>