symfony2 doctrine如何删除查询中的相关对象?

I have, for example, a "products" entity and an "orders" entity and a "customers" entity. using doctrine, if I execute

return $this->getEntityManager()
        ->createQuery(
            'SELECT p FROM MyApplicationBundle:Products p ORDER BY p.name ASC'
        )
        ->getResult();

I get a collection of products with orders and customers related information. this collection is too big and I'm worried it can take too much memory. is there a way to take only the products information? I'd need it only for this query so I don't want to modify the relation in the product entity class.

thanks

You can mark the association as Extra Lazy in your Entity, this should prevent it from being automatically included in your query.