title: Symfony - Query Builder with Join
body: <p>i am a bit confused, why this is not working.</p>
  
  <p>I have two Entities, one entity called user and one entity called shed. 
  1 user can have many sheds and 1 shed can belong to 1 user. </p>
  
  <p>they are connected with a ManyToOne</p>
  
  <pre><code>class User
  {
  
   /**
   * @var boolean
   *
   * @ORM\Column(columnDefinition="TINYINT(1) NOT NULL")
   */
  protected $active = true;
  
  
   /**
    * @ORM\OneToMany(targetEntity="AppBundle\Entity\Shed", mappedBy="user")
    */
    protected $shed;
  }
  
  class Shed
  {
       /**
   * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="shed")
   * @ORM\JoinColumn(name="user", referencedColumnName="id", onDelete="CASCADE")
   *
   * @var User
   */
  protected $user;
  
  /**
   * @var boolean
   *
   * @ORM\Column(columnDefinition="TINYINT(1) NOT NULL")
   */
  protected $published = false;
  }
  </code></pre>
  
  <p>What i want to achieve is, that i query the newest 3 sheds from active users that are published. </p>
  
  <p>In my ShedRepository i have the following method:</p>
  
  <pre><code>class ShedRepository
  {
      public function getNewestSheds()
      {
          $query = $this-&gt;createQueryBuilder('s')
              -&gt;join('AppBundle:User', 'u')
              -&gt;andWhere('u.active = 1')
              -&gt;andWhere('s.published = 1')
              -&gt;orderBy('s.createdAt', 'DESC')
              -&gt;setMaxResults(3)
              -&gt;getQuery();
  
          return $query-&gt;getResult();
        }
  }
  </code></pre>
  
  <p>When the shed.published property is 0 the shed is not shown. if the shed is published but user is inactive the shed is shown too, but shouldnt. 
  Can anyone help me with it? </p>