title: How can I prevent loading of related entities in Symfony2?
body: <p>I have two entities, Order and Orderline with one-to-many relationship. I have a listing where I need only data from orders, but Doctrine makes query for orderlines for each order. I haven't joined Orderlines in the query. How can prevent Doctrine for querying the orderlines?</p>
  
  <p>Query used in controller:</p>
  
  <pre><code>$query = $em-&gt;createQuery("SELECT o FROM SomeBundle:Order o JOIN o.shop s JOIN s.user u WHERE u.id = :user_id AND o.status = :status")
      -&gt;setParameter('user_id', $user-&gt;getId())
      -&gt;setParameter('status', 'paid');
  $orders = $query-&gt;getResult();
  </code></pre>
  
  <p>One-to-many annotation in Order class:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Orderline", mappedBy="order")
   */
  protected $orderlines;
  </code></pre>
  
  <p>Many-to-one annotation in Orderline class:</p>
  
  <pre><code>/**
   * @ORM\ManyToOne(targetEntity="Order", inversedBy="orderlines")
   */
  protected $order;
  </code></pre>