doctrine/orm · error · RuntimeException

Cannot use SimpleObjectHydrator with a ResultSetMapping that

Error message

Cannot use SimpleObjectHydrator with a ResultSetMapping that contains scalar mappings.

What it means

Error "Cannot use SimpleObjectHydrator with a ResultSetMapping that contains scalar mappings." thrown in doctrine/orm.

Source

Thrown at src/Internal/Hydration/SimpleObjectHydrator.php:38

use function is_array;
use function key;
use function reset;
use function sprintf;

class SimpleObjectHydrator extends AbstractHydrator
{
    use SQLResultCasing;

    private ClassMetadata|null $class = null;

    protected function prepare(): void
    {
        if (count($this->resultSetMapping()->aliasMap) !== 1) {
            throw new RuntimeException('Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result.');
        }

        if ($this->resultSetMapping()->scalarMappings) {
            throw new RuntimeException('Cannot use SimpleObjectHydrator with a ResultSetMapping that contains scalar mappings.');
        }

        $this->class = $this->getClassMetadata(reset($this->resultSetMapping()->aliasMap));
    }

    protected function cleanup(): void
    {
        parent::cleanup();

        $this->uow->triggerEagerLoads();
        $this->uow->hydrationComplete();
    }

    /**
     * {@inheritDoc}
     */
    protected function hydrateAllData(): array
    {

View on GitHub (pinned to d9b9ff7301)

When it happens

Trigger: Thrown at src/Internal/Hydration/SimpleObjectHydrator.php:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21). Data as JSON: /api/errors/0f19ddcbc95fd5c2. Report an issue: GitHub.