Symfony 2 Doctrine 2 Attempted to call an undefined method named "getName" of class "Doctrine\ORM\PersistentCollection"
<p>I'm trying to do a fetch associated objects as shown in documentation symfony 2. It shows me an error like title this post. what I doing wrong ?</p>

<pre><code>public function indexAction( )       


{

$UserRepo = $this-&gt;getDoctrine()-&gt;getRepository('UserUserBundle:User');
 $all = $UserRepo-&gt;findOneBy(array('username'=&gt;'macq'));
 $allOwner = $all-&gt;getOwner()-&gt;getName();

    return array(
    'allOwner'=&gt;$allOwner,
     );
}
</code></pre>

<p>}</p>

<pre><code>/**
 * @ORM\ManyToOne(
 *      targetEntity ="User\UserBundle\Entity\User",
 *      inversedBy ="owner"
 * )
 * @ORM\JoinColumn(
 *      name = "user_id",
 *      referencedColumnName ="id",
 *      
 * )
 */
protected $user;


**
 * @ORM\OneToMany(
 *      targetEntity ="Property\ManagementBundle\Entity\Owner",
 *      mappedBy ="user"
 * )
 */
protected $owner;
</code></pre>