I've run into an issue with the doctrine 2 paginator. I made a very basic example which will explain the situation:
$queryBuilder->select('entity');
$queryBuilder->join('SomeModule\Entity\SomeEntity', 's', 'WITH', '(s.objectClass = :class AND p.foreignKey = :foreignkey');
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($queryBuilder);
causes the error 'Cannot count query which selects two FROM components, cannot make distinction' in: Doctrine\ORM\Tools\Pagination\WhereInWalker
It does that because there are two components, but in this case, no columns are selected from the 'SomeModule\Entity\SomeEntity':
if (count($rootComponents) > 1) {
throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction");
}
In my case, it works when I comment the exception, because it will just use the first $rootComponent. Does anyone know a solution for this exotic join, without changing/extending the WhereInWalker class?
I used version 2.4.6 of the ORM, when I use the master branch: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php The issue is resolved. But I'd rather not use the master branch in our environment.