Your Location is: Home > Doctrine-orm

Eager Loading disabled by Custom Extension

From: Beijing View: 2724 Tomas 


I have a database table called Accounts and there's a column isCustomer. To make my /Entity/Customer.php only return accounts that are actual customers I used a Custom Doctrine ORM Extension

There is also a relation with the Contacts table. I'd like to add Contacts to Customer when the /customers URL is requested. This relation exists and is working properly, and is also eager loading.

The moment I created the /Doctrine/CustomerExtension.php the result set only consists of customer accounts (with contacts), like I expected. But at the same time the Eager Loading ORM Extension doesn't work anymore. All relations are lazy loaded now even with @ORM\ManyToOne(fetch="EAGER") on every relationship.

How do I add $queryBuilder->andWhere('isCustomer = 1'); by default AND keep eager loading?

  • My first attempt has been to add normalizationContext={ "groups": {"boost"} } to /Entity/Customer.php and put all the properties in that group. It didn't fix eager loading :(

Best answer