# DDC-2516: Undefined offset in ObjectHydrator while working with iterableResult#3238

Open
opened this Issue · 2 comments

### 2 participants

Jira issue originally created by user johanny:

Following this documentation page http://doctrine-orm.readthedocs.org/en/2.0.x/reference/batch-processing.html#iterating-large-results-for-data-processing I tried to create a batch process on 75k entities. But an error came in the ObjectHydrator on line 511 there's an Undefined offset. Now, i just use the SimpleObjectHydrator and it solve the problem. but i'm wondering if it's a real bug or just a miss use of Doctrine.

Comment created by @beberlei:

Can you provide more information? The stack trace of the error for example? The entity you try to process+mapping and the DQL query. The current information is not enough to reproduce this error.

Comment created by johanny:

Hello Benjamin,

here is the Entity and with the corresponding Mapping :

    /****
* @var string
* @ORM\Id
* @ORM\Column(name="id_source", type="string", length=32, nullable=false)
*/
private $idSource; /**** * @var string * * @ORM\Column(name="id_page", type="string", length=32, nullable=false) */ private$idPage;

/****
* @var string
*
* @ORM\Column(name="url", type="string", length=500, nullable=true)
*/
private $url; /**** * @var float * * @ORM\Column(name="similitude", type="decimal", nullable=true) */ private$similitude;

/****
* @var string
*
*/
private $alerte;  The Entity have been generated by using this documentation page : http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html In this project I work with 2 databases, and one of it already exist. Working with symfony I use the DQL Query obtain with those methods :  public function getAllUrl($limit)
{
$queryBuilder =$this->createQueryBuilder('s');

$this->setStatsParameters($queryBuilder);

$queryBuilder->setMaxResults($limit);

return $queryBuilder->getQuery() ->iterate(); } private function setStatsParameters(\Doctrine\ORM\QueryBuilder$queryBuilder)
{
$queryBuilder->where('s.similitude > 1') ->andWhere('s.url NOT LIKE :url') ->setParameter('url', 'some_string%'); }  And here is the stack trace, when the eror comes : Exception trace: () at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511 Symfony\Component\Debug\ErrorHandler->handle() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511 Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\AbstractHydrator.php:136 Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateRow() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\IterableResult.php:76 Doctrine\ORM\Internal\Hydration\IterableResult->next() at \path\to\project\src\Compilatio\RecolteurBundle\Command\RecolteurCommand.php:42 CompanyName\RecolteurBundle\Command\RecolteurCommand->execute() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:244 Symfony\Component\Console\Command\Command->run() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:906 Symfony\Component\Console\Application->doRunCommand() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191 Symfony\Component\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:80 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121 Symfony\Component\Console\Application->run() at \path\to\project\app\console:27  You can also see here the source code that lead to this error : $sources = $urlLoader->getAllSources(50000);$number = 0;
while (($source =$sources->next()) !== false) {
$number<ins></ins>; } echo 'Nombre de sources : ' .$number;


There are all the information you ask, if you need more just tell me. For now i can see how to be more specific. Remember that if I switch the hydrator to Query::HYDRATE_SIMPLEOBJECT it solve the bug.

I hope all of this will help.

Regards,

Johanny

was assigned by doctrinebot