[DDC-1819] Allow ResultSetMapping to be used for objects that are not entities Created: 11/May/12  Updated: 14/May/12

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Marijn Huizendveld Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


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 by Benjamin Eberlei [ 11/May/12 ]

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 by Marijn Huizendveld [ 13/May/12 ]

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

Comment by Marijn Huizendveld [ 14/May/12 ]

I've started working on the test suite in this PR.

Generated at Wed Dec 02 00:22:59 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.