From b3c01903b4f719714047342f43b590d9276b927a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Tue, 15 Mar 2011 20:03:05 +0100 Subject: [PATCH] DDC-952 - Optimization --- .../ORM/Internal/Hydration/SimpleObjectHydrator.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 68cdc3653..eb6717b30 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -33,6 +33,8 @@ class SimpleObjectHydrator extends AbstractHydrator */ private $class; + private $declaringClasses = array(); + protected function _hydrateAll() { $result = array(); @@ -51,6 +53,11 @@ class SimpleObjectHydrator extends AbstractHydrator { if (count($this->_rsm->aliasMap) == 1) { $this->class = $this->_em->getClassMetadata(current($this->_rsm->aliasMap)); + if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { + foreach ($this->_rsm->declaringClasses AS $column => $class) { + $this->declaringClasses[$column] = $this->_em->getClassMetadata($class); + } + } } else { throw new \RuntimeException("Cannot use SimpleObjectHydrator with a ResultSetMapping not containing exactly one object result."); } @@ -87,7 +94,7 @@ class SimpleObjectHydrator extends AbstractHydrator foreach ($sqlResult as $column => $value) { if (isset($this->_rsm->fieldMappings[$column])) { $realColumnName = $this->_rsm->fieldMappings[$column]; - $class = $this->_em->getClassMetadata($this->_rsm->declaringClasses[$column]); + $class = $this->declaringClasses[$column]; if ($class->name == $entityName || is_subclass_of($entityName, $class->name)) { $field = $class->fieldNames[$realColumnName]; if (isset($data[$field])) {