/** @override */
 protected function _prepare()
 {
     $this->_identifierMap = $this->_resultPointers = $this->_idTemplate = array();
     $this->_resultCounter = 0;
     if (!isset($this->_hints['deferEagerLoad'])) {
         $this->_hints['deferEagerLoad'] = true;
     }
     foreach ($this->_rsm->aliasMap as $dqlAlias => $className) {
         $this->_identifierMap[$dqlAlias] = array();
         $this->_idTemplate[$dqlAlias] = '';
         $class = $this->_em->getClassMetadata($className);
         if (!isset($this->_ce[$className])) {
             $this->_ce[$className] = $class;
         }
         // Remember which associations are "fetch joined", so that we know where to inject
         // collection stubs or proxies and where not.
         if (isset($this->_rsm->relationMap[$dqlAlias])) {
             if (!isset($this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]])) {
                 throw HydrationException::parentObjectOfRelationNotFound($dqlAlias, $this->_rsm->parentAliasMap[$dqlAlias]);
             }
             $sourceClassName = $this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]];
             $sourceClass = $this->_getClassMetadata($sourceClassName);
             $assoc = $sourceClass->associationMappings[$this->_rsm->relationMap[$dqlAlias]];
             $this->_hints['fetched'][$sourceClassName][$assoc['fieldName']] = true;
             if ($sourceClass->subClasses) {
                 foreach ($sourceClass->subClasses as $sourceSubclassName) {
                     $this->_hints['fetched'][$sourceSubclassName][$assoc['fieldName']] = true;
                 }
             }
             if ($assoc['type'] != ClassMetadata::MANY_TO_MANY) {
                 // Mark any non-collection opposite sides as fetched, too.
                 if ($assoc['mappedBy']) {
                     $this->_hints['fetched'][$className][$assoc['mappedBy']] = true;
                 } else {
                     if ($assoc['inversedBy']) {
                         $inverseAssoc = $class->associationMappings[$assoc['inversedBy']];
                         if ($inverseAssoc['type'] & ClassMetadata::TO_ONE) {
                             $this->_hints['fetched'][$className][$inverseAssoc['fieldName']] = true;
                             if ($class->subClasses) {
                                 foreach ($class->subClasses as $targetSubclassName) {
                                     $this->_hints['fetched'][$targetSubclassName][$inverseAssoc['fieldName']] = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /** @override */
 protected function prepare()
 {
     $this->_identifierMap = $this->_resultPointers = $this->_idTemplate = array();
     $this->_resultCounter = 0;
     if (!isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) {
         $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true;
     }
     foreach ($this->_rsm->aliasMap as $dqlAlias => $className) {
         $this->_identifierMap[$dqlAlias] = array();
         $this->_idTemplate[$dqlAlias] = '';
         if (!isset($this->_ce[$className])) {
             $this->_ce[$className] = $this->_em->getClassMetadata($className);
         }
         // Remember which associations are "fetch joined", so that we know where to inject
         // collection stubs or proxies and where not.
         if (!isset($this->_rsm->relationMap[$dqlAlias])) {
             continue;
         }
         if (!isset($this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]])) {
             throw HydrationException::parentObjectOfRelationNotFound($dqlAlias, $this->_rsm->parentAliasMap[$dqlAlias]);
         }
         $sourceClassName = $this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]];
         $sourceClass = $this->_getClassMetadata($sourceClassName);
         $assoc = $sourceClass->associationMappings[$this->_rsm->relationMap[$dqlAlias]];
         $this->_hints['fetched'][$this->_rsm->parentAliasMap[$dqlAlias]][$assoc['fieldName']] = true;
         if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) {
             continue;
         }
         // Mark any non-collection opposite sides as fetched, too.
         if ($assoc['mappedBy']) {
             $this->_hints['fetched'][$dqlAlias][$assoc['mappedBy']] = true;
             continue;
         }
         // handle fetch-joined owning side bi-directional one-to-one associations
         if ($assoc['inversedBy']) {
             $class = $this->_ce[$className];
             $inverseAssoc = $class->associationMappings[$assoc['inversedBy']];
             if (!($inverseAssoc['type'] & ClassMetadata::TO_ONE)) {
                 continue;
             }
             $this->_hints['fetched'][$dqlAlias][$inverseAssoc['fieldName']] = true;
         }
     }
 }