When using Doctrine 2 hydration you can sometimes encounter issue when you get one result instead of many results. Doctrine 2 requires every entity to have Id annotation. Please use it carefully, because when using Doctrine 2 QueryBuilder \Doctrine\ORM\AbstractQuery::getResult
You will not get records having not unique @Id fields. And no even PHP warnings.
\Doctrine\ORM\Internal\Hydration\ObjectHydrator::hydrateRowData will just skip them. So please put @Id annotation on unique fields or use composit keys.
\ORM\AbstractQuery::getArrayResult does not depend on such unique id fields.
Leave a Reply