Skip to content


DDC-1819: Allow ResultSetMapping to be used for objects that are not entities #2476

doctrinebot opened this Issue · 3 comments

2 participants


Jira issue originally created by user marijn:

Currently Doctrine\ORM\Query\ResultSetMapping can only be used to query the database for entities using the EntityManager::createNativeQuery method. It would be great if we could use this as well for objects that are not entities. That way we can create simple DTO's and map them to a query using the ResultSetMapping.

I'll open a PR If there are no objections.


Comment created by @beberlei:

Good idea. You could make this happen by adding a ArbitraryObjectHydrator that does not use the ClassMetadata but creates ReflectionProperty instances during the hydration.

Api would then be:

$rsm = new ResultSetMapping();

$query = $em->createNativeQuery($sql, $rsm);
$objects = $query->getResult(Query::HYDRATOR*ARBITRARY*OBJECTS);

Comment created by marijn:

Thanks for your input. I'll try to work on some tests this week.

@beberlei beberlei was assigned by doctrinebot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.