'Proper way to run multiple hydration query with doctrine and querybuilder
I am having an issue running a query with multiple nested joins. I discovered that doctrine has a problem where if you run a query with more than two joins it quickly becomes very expensive.
I found an article here: https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/ describing the solution via multiple hydrations technique, however I am running into an issue when I attempt to run the query. I can't seem to get my partial right so that my second query is running off of the pre-existing hydrated data from the first query.
basically I need to be able to join the result off of the hydrated data ca.member (which is an array)
Here is my Query:
//first query to grab and hydrate data
$qb = $this->createQueryBuilder('ca');
$case_alterations = $qb->select('ca, cg, cma')
->innerJoin('ca.gene', 'cg')
->leftJoin('ca.mask', 'm')
->leftJoin('ca.member', 'cma')
->where('ca.case_id = :case_id')
->andWhere('m.id IS NULL')
->setParameter('case_id', $case_id)
->getQuery()
->getResult()
;
//second query should grab the already hydrated data in memory and perform the join
$query = $this->createQueryBuilder('ca')
->select('partial ca.{member}, cr')
->leftJoin('ca.result', 'cr')
->getQuery()
->getResult()
;
And here is the error I keep hitting because its referencing case from the first query rather than the subset, member:
\Entity\Case has no association named result
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
