private function loadReferenceCollection(PersistentCollection $collection)
 {
     $rows = $collection->getData();
     if (count($rows) === 0) {
         return;
     }
     $mapping = $collection->getMapping();
     $useKey = boolval($mapping['association'] & ClassMetadata::ASSOCIATION_USE_KEY);
     if (is_string(reset($rows))) {
         if ($useKey) {
             $keys = array_flip($rows);
         }
         $results = $this->binding->query(sprintf('SELECT FROM [%s]', implode(',', array_values($rows))));
     } else {
         // data was already loaded
         $results = $rows;
     }
     foreach ($results as $key => $data) {
         $document = $this->uow->getOrCreateDocument($data);
         if ($useKey) {
             $key = isset($keys) ? $keys[$data['@rid']] : $key;
             $collection->set($key, $document);
         } else {
             $collection->add($document);
         }
     }
 }