title: "NOT EXISTS" Query with Many to Many Relation Doctrine Symfony3
body: <p>I would like to build a query that brings me all the games for a logged in user that he has not yet joined. For this I have built these 2 Entities. They are connected by many to many.</p>
  
  <pre><code>class Game
  {
      public function __construct()
      {
          $this-&gt;users = new ArrayCollection();
      }
  
      /**
       * @ORM\Column(type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       *
       * @var Users[]
       *
       * @ORM\ManyToMany(
       *     targetEntity="Domain\Entity\User",
       *     inversedBy="user",
       *     fetch="EAGER"
       * )
       */
      private $users;
  /**
   * @return array
   */
  public function getUsers() : array
  {
      return $this-&gt;users-&gt;getValues();
  }
  
  /**
   * @param User $users
   */
  public function setUser($users)
  {
      if(is_array($users)){
          /** @var User $user */
          foreach ($users as $user){
              $this-&gt;users-&gt;add($user);
          }
      } else {
          $this-&gt;users-&gt;add($users);
      }
  }
  }
  </code></pre>
  
  <p>And the User Entity</p>
  
  <pre><code>class User implements AdvancedUserInterface
  {
  
      /**
       * @ORM\Column(type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
  }
  </code></pre>
  
  <p>The Entities has more attributes but i think they are not important. 
  Also I tried these Query, but it doesn't work. </p>
  
  <pre><code>/**
   * @param User $user
   * @return array
   */
  public function fetchAllNonActivatedWhereYouNotJoin(User $user): array
  {
  
      $qb = $this-&gt;createQueryBuilder('g');
      $qb-&gt;select('g')
          -&gt;innerJoin('g.users', 'u')
          -&gt;where('u.id != :user')
          -&gt;andWhere('g.activate = 0')
          -&gt;setParameter('user', $user-&gt;getId())
          -&gt;getQuery()-&gt;getResult();
  
  
      return $qb-&gt;getQuery()-&gt;getResult();
  }
  </code></pre>
  
  <p>Does anyone know a solution? Its Symfony 3 and Doctrine in PHP 7.1</p>