Using dql I tried to check if a entity is member of a collections subentity
entites:
product
customer
customer.orders (collection)
customer.orders.products (collection, type: product)
customer.cancellations.productContainers (collection)
customer.cancellations.productContainers.product (entity, type: product)
A customer has multiple orders. An order has multiple products. A customer has multiple cancellations. A cancellations has multiple productContainers. A productContainer has a product.
problem
I want to get all ordered products which are not cancelled.
$qb->select('c, d, p')
->from('XyzBundle:Customer', 'c')
->leftJoin('c.orders', 'co')
->leftJoin('co.products', 'cop')
->leftJoin('c.cancellation', 'ca')
->leftJoin('ca.productContainers', 'cap')
->leftJoin('cap.product', 'capp')
->andWhere('cop NOT MEMBER OF capp')
however this does not work, because ca.productContainers is the collection field and not its supentity ca.productContainers.product. thus I get the following error:
CRITICAL - Uncaught PHP Exception Doctrine\ORM\Query\QueryException:
"[Semantical Error] line 0, col 414 near 'product': Error: Invalid PathExpression.
Must be a CollectionValuedAssociationField." at
/vagrant/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 4 9
Any suggestions how to solve this?