title: Doctrine OneToMany relation returns nothing
body: <p><strong>Context</strong></p>
  
  <p>I have a User entity which has one Team and Team which can have several users.
  I'm trying to fetch one team and to get the list of users associated with.</p>
  
  <p><strong>User Entity</strong></p>
  
  <pre><code>&lt;?php
  
  namespace Enterprise\PortailBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * User entity class
   *
   * @ORM\Table(name="user")
   * @ORM\Entity(repositoryClass="Enterprise\PortailBundle\Repository\TeamRepository")
   * @category Entity
   * @package Entity
   */
  class User
  {
      /*
       * Relationship Mapping Metadata
       */
  
      public function __toString()
      {
          return  $this-&gt;firstName . ' - ' . $this-&gt;lastName . ' - ' . $this-&gt;enterprise . ' - ' . $this-&gt;team;
      }
  
      /**
       * @ORM\ManyToOne(targetEntity="Team", inversedBy="users")
       * @ORM\JoinColumn(name="team_id", referencedColumnName="id")
       */
      private $team;
      /*
       * Autogenerated methods / variables
       */
  
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @Assert\Length(min=2, minMessage="Le prénom de l'utilisateur doit être supérieur à 2 caractères.")
       * @Assert\Length(max=32, maxMessage="Le prénom de l'utiisateur doit être inférieur à 32 caractères.")
       * @ORM\Column(name="firstName", type="string", length=32)
       */
      private $firstName;
  
      /**
       * @var string
       *
       * @Assert\Length(min=2, minMessage="Le nom de l'utilisateur doit être supérieur à 2 caractères.")
       * @Assert\Length(max=64, maxMessage="Le nom de l'utilisateur doit être inférieur à 64 caractères.")
       * @ORM\Column(name="lastName", type="string", length=64)
       */
      private $lastName;
  
      /**
       * @var string
       *
       * @Assert\Length(min=2, minMessage="Le nom de l'entreprise doit être supérieur à 2 caractères.")
       * @Assert\Length(max=64, maxMessage="Le nom de l'entreprise doit être inférieur à 64 caractères.")
       * @ORM\Column(name="enterprise", type="string", length=64)
       */
      private $enterprise;
  
      /**
       * @Assert\File(mimeTypes={ "image/jpeg", "image/jpg", "image/png" })
       * @ORM\Column(name="image", type="string")
       */
      private $image;
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set firstName
       *
       * @param string $firstName
       *
       * @return User
       */
      public function setFirstName($firstName)
      {
          $this-&gt;firstName = $firstName;
  
          return $this;
      }
  
      /**
       * Get firstName
       *
       * @return string
       */
      public function getFirstName()
      {
          return $this-&gt;firstName;
      }
  
      /**
       * Set lastName
       *
       * @param string $lastName
       *
       * @return User
       */
      public function setLastName($lastName)
      {
          $this-&gt;lastName = $lastName;
  
          return $this;
      }
  
      /**
       * Get lastName
       *
       * @return string
       */
      public function getLastName()
      {
          return $this-&gt;lastName;
      }
  
      /**
       * Set enterprise
       *
       * @param string $enterprise
       *
       * @return User
       */
      public function setEnterprise($enterprise)
      {
          $this-&gt;enterprise = $enterprise;
  
          return $this;
      }
  
      /**
       * Get enterprise
       *
       * @return string
       */
      public function getEnterprise()
      {
          return $this-&gt;enterprise;
      }
  
      /**
       * Set image
       *
       * @param string $image
       *
       * @return User
       */
      public function setImage($image)
      {
          $this-&gt;image = $image;
  
          return $this;
      }
  
      /**
       * Get image
       *
       * @return string
       */
      public function getImage()
      {
          return $this-&gt;image;
      }
  
      /**
       * Set team
       *
       * @param Team $team
       *
       * @return User
       */
      public function setTeam(Team $team)
      {
          $this-&gt;team = $team;
  
          return $this;
      }
  
      /**
       * Get team
       *
       * @return Team
       */
      public function getTeam()
      {
          return $this-&gt;team;
      }
  }
  </code></pre>
  
  <p><strong>Team entity</strong></p>
  
  <pre><code>    &lt;?php
  
      namespace Enterprise\PortailBundle\Entity;
  
      use Doctrine\Common\Collections\ArrayCollection;
      use Doctrine\ORM\Mapping as ORM;
      use Symfony\Component\Validator\Constraints as Assert;
  
      /**
       * Team entity class
       *
       * @ORM\Table(name="team")
       * @ORM\Entity(repositoryClass="Enterprise\PortailBundle\Repository\TeamRepository")
       * @category Entity
       * @package Entity
       */
      class Team
      {
          public function __toString()
          {
              return  $this-&gt;name . ' - ' . $this-&gt;role;
          }
  
          /**
           * @ORM\OneToMany(targetEntity="User", mappedBy="team")
           */
          private $users;
  
          public function __construct()
          {
              $this-&gt;users = new ArrayCollection();
          }
  
          /*
           * Autogenerated methods / variables
           */
  
          /**
           * @var int
           *
           * @ORM\Column(name="id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          private $id;
  
          /**
           * @var string
           *
           * @Assert\Length(min=2, minMessage="Le nom de l'équipe doit être supérieur à 2 caractères.")
           * @Assert\Length(max=64, maxMessage="Le nom de l'équipe doit être inférieur à 64 caractères.")
           * @ORM\Column(name="name", type="string", length=64)
           */
          private $name;
  
          /**
           * @var string
           *
           * @Assert\Length(min=2, minMessage="Le role de l'équipe doit être supérieur à 2 caractères.")
           * @Assert\Length(max=64, maxMessage="Le role de l'équipe doit être inférieur à 64 caractères.")
           * @ORM\Column(name="role", type="string", length=64)
           */
          private $role;
  
          /**
           * Get id
           *
           * @return int
           */
          public function getId()
          {
              return $this-&gt;id;
          }
  
          /**
           * Set name
           *
           * @param string $name
           *
           * @return Team
           */
          public function setName($name)
          {
              $this-&gt;name = $name;
  
              return $this;
          }
  
          /**
           * Get name
           *
           * @return string
           */
          public function getName()
          {
              return $this-&gt;name;
          }
  
          /**
           * Get users
           *
           * @return \Doctrine\Common\Collections\Collection
           */
          public function getUsers()
          {
              return $this-&gt;users;
          }
  
          /**
           * Set role
           *
           * @param string $role
           *
           * @return Team
           */
          public function setRole($role)
          {
              $this-&gt;role = $role;
  
              return $this;
          }
  
          /**
           * Get role
           *
           * @return string
           */
          public function getRole()
          {
              return $this-&gt;role;
    }
  }
  </code></pre>
  
  <p><strong>Doctrine version</strong></p>
  
  <p>2.5.14</p>
  
  <p><strong>The database</strong></p>
  
  <p>The team and the user table
  <a href="https://i.stack.imgur.com/QRuZ9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QRuZ9.jpg" alt="enter image description here"></a></p>
  
  <p>In my controller I succeed to get informations when going from user to the team</p>
  
  <pre><code>$user = $this-&gt;getDoctrine()-&gt;getRepository(User::class)-&gt;find(6);
  dump($user);
  $teamName = $user-&gt;getTeam()-&gt;getName();
  dump($teamName);
  </code></pre>
  
  <p>But the contrary doesn't returns me the list of users</p>
  
  <pre><code>$team = $this-&gt;getDoctrine()-&gt;getRepository(Team::class)-&gt;find(1);
  dump($team);
  $users = $team-&gt;getUsers();
  dump($users);
  </code></pre>
  
  <p>The output of this last part is:
  <a href="https://i.stack.imgur.com/EPDR1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EPDR1.jpg" alt="enter image description here"></a></p>
  
  <p>So my question is why <code>$users = $team1-&gt;getUsers();</code> doesn't return the list of users ?</p>
  
  <p>Thanks</p>