protected function fetch(SqlBuilder $builder, $hasJoin, array $values)
 {
     $primaryKey = $this->targetRepository->getMapper()->getStorageReflection()->getStoragePrimaryKey()[0];
     $builder->addWhere($primaryKey, $values);
     $builder->addSelect(($hasJoin ? 'DISTINCT ' : '') . $builder->getTableName() . '.*');
     $result = $this->context->queryArgs($builder->buildSelectQuery(), $builder->getParameters());
     $entities = [];
     while ($data = $result->fetch()) {
         $entity = $this->targetRepository->hydrateEntity((array) $data);
         $entities[$entity->id] = $entity;
     }
     return new EntityContainer($entities);
 }
 protected function calculateCacheKey(SqlBuilder $builder, $values)
 {
     return md5($builder->buildSelectQuery() . json_encode($builder->getParameters()) . json_encode($values));
 }