private function getQueryAliasAndFields(
        $criteriaBy,
        $criteria,
        ClassMetadata $metadata,
        QueryBuilder $queryBuilder
    ) {
        $alias = null;
        $fields = null;

        if ($criteriaBy && $criteria) {
            $previousId = 97;

            if ($this->isTableRelation($metadata, $criteriaBy)) {
                $associations = explode('.', $criteriaBy);
                $fields = $associations;
                for ($i = 0; $i < count($associations) - 1; ++$i) {
                    if (false === $this->isTableRelation($metadata, $associations[$i] . '.' . $associations[$i + 1])) {
                        break;
                    }
                    $queryBuilder->innerJoin(chr($previousId) . '.' . $associations[$i], chr($previousId + 1));
                    ++$previousId;
                    foreach ($metadata->getAssociationMappings() as $associationMapping) {
                        if ($associationMapping['fieldName'] === $associations[$i]) {
                            $metadata = $this->manager->getClassMetadata($associationMapping['targetEntity']);
                        }
                    }
                    unset($fields[$i]);
                }
                $alias = chr($previousId);
                $fields = implode('.', $fields);
            } else {
                $alias = chr($previousId);
            }
        }

        return [
            $alias,
            $fields,
        ];
    }