doctrine/DoctrineBundle — pull request #167 by jelmersnoeck (2013-03-12 20:24:41+00:00)
Title: ResultSetMapping

# ResultSetMapping

In the Doctrine core there is a ResultSetMapping object which works with entity namespaces. The DoctrineBundle provides a way to "shortcut" these entity namespaces.

Unfortunately, this isn't the case with the ResultSetMapper. If you use these shortcuts, the ObjectHydrator will store these values with their shortcut name, but it will search for the relation data based upon their full class name. This gives a PHP notice, "Notice: Undefined index: Full/Entity/Class in vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php line 427"
(https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php#L476)

This ResultSetMapping class provides a small wrapper around the Doctrine ResultSetMapping class and uses the correct key value.

## Code example
This will throw the PHP Notice (and the code will not work, if error suppressing is enabled):
```
$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('AcmeExampleBundle:Entity', 'e');
$rsm->addField…
…

// related object
$rsm->addJoinedEntityResult('AcmeExampleBundle:Related', 'r');
$rsm->addField…
…
```

This will not throw a PHP Notice (since the shortcuts are converted to actual classes):
```
$rsm = new \Doctrine\Bundle\DoctrineBundle\Query\ResultSetMapping;
$rsm->addEntityResult('AcmeExampleBundle:Entity', 'e');
$rsm->addField…
…

// related object
$rsm->addJoinedEntityResult('AcmeExampleBundle:Related', 'r');
$rsm->addField…
…
```