[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


 Description   

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.



 Comments   
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 Thu Nov 27 17:25:29 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.