title: I get friends and all other users when trying to load only friends of the current user
body: <p>I am trying to load friends of a specific user after asking why I get null values of the friend of the user data it was responded that it was because of the lazy loading. So I was advised to add JOIN and I admit this was a miss from my side. But after adding the JOIN I get the data of the friend in the result and then I receive all the users from my users table for which I have not asked.</p>
  
  <p>I have already tried removing the myuser from the SELECT, but this way I get the lazy loading problem again. I have tried LEFT JOIN (I admit it was dumb try from my side). But how can I correct this when there is no ON in the Doctrine Query Language.</p>
  
  <p>My Entity(Friends):</p>
  
  <pre><code>class Friends
  {
  
  /**
   * @ORM\Id()
   * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="myfriends")
   * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
   */
  
  private $friendsWithMe;
  
  
  /**
   * @ORM\Id()
   * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="friendof")
   * @ORM\JoinColumn(name="friend_id", referencedColumnName="id", nullable=false)
   */
  
  private $afriendof;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="status", type="smallint")
   */
  private $status;
  
  
  
  /**
   * @return User
   */
  public function getFriendsWithMe()
  {
      return $this-&gt;friendsWithMe;
  }
  
  /**
   * @param mixed $friendsWithMe
   */
  public function setFriendsWithMe($friendsWithMe)
  {
      $this-&gt;friendsWithMe = $friendsWithMe;
  }
  
  /**
   * @return User
   */
  public function getAfriendof()
  {
      return $this-&gt;afriendof;
  }
  
  /**
   * @param mixed $afriendof
   */
  public function setAfriendof($afriendof)
  {
      $this-&gt;afriendof = $afriendof;
  }
  
  /**
   * @return integer
   */
  public function getStatus()
  {
      return $this-&gt;status;
  }
  
  /**
   * @param integer $status
   */
  public function setStatus($status)
  {
      $this-&gt;status = $status;
  }
  }
  </code></pre>
  
  <p>My Entity(User):</p>
  
  <pre><code>class User implements UserInterface
  {
  /**
   * @var int
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;
   public function __construct()
  {
      $this-&gt;userPosts = new ArrayCollection();
      $this-&gt;myfriends = new ArrayCollection();
      $this-&gt;friendof = new ArrayCollection();
  }
  
  
  /**
   * @var
   * @ORM\OneToMany(targetEntity="AppBundle\Entity\Friends", mappedBy="afriendof")
   */
  
  private $friendof;
  /**
   * @var
   * @ORM\OneToMany(targetEntity="AppBundle\Entity\Friends", mappedBy="friendsWithMe")
   */
  private $myfriends;
  </code></pre>
  
  <p>My Repository(FriendsRepository):</p>
  
  <pre><code>public function personalFriends($userId){
  
      $em = $this-&gt;getEntityManager();
      $result = $em-&gt;createQuery('SELECT friends, myuser FROM AppBundle\Entity\Friends friends 
      INNER JOIN AppBundle\Entity\User myuser WHERE friends.friendsWithMe = :userId AND friends.status = 1');
      $result-&gt;setParameter('userId', $userId);
      return $result-&gt;getResult();
  }
  </code></pre>
  
  <p>The place where I call the repository:</p>
  
  <pre><code>public function indexAction(Request $request)
      {
  
      $user = $this-&gt;get('security.token_storage')-&gt;getToken()-&gt;getUser();
      $userId = $user-&gt;getId();
      $friends = $this-&gt;getDoctrine()-&gt;getRepository(Friends::class)-&gt;personalFriends($userId);
      dump($friends);
      exit();
  </code></pre>
  
  <p>Results that I get now:
  <a href="https://pastebin.com/2M4SYTLb" rel="nofollow noreferrer">https://pastebin.com/2M4SYTLb</a>
  Results that I expect:
  <a href="https://pastebin.com/BxsC9QbE" rel="nofollow noreferrer">https://pastebin.com/BxsC9QbE</a></p>