private function processParameterMappings($paramMappings)
    {
        $sqlParams = [];
        $types     = [];

        foreach ($this->parameters as $parameter) {
            $key   = $parameter->getName();
            $value = $parameter->getValue();
            $rsm   = $this->getResultSetMapping();

            if (! isset($paramMappings[$key])) {
                throw QueryException::unknownParameter($key);
            }

            if (isset($rsm->metadataParameterMapping[$key]) && $value instanceof ClassMetadata) {
                $value = $value->getMetadataValue($rsm->metadataParameterMapping[$key]);
            }

            if (isset($rsm->discriminatorParameters[$key]) && $value instanceof ClassMetadata) {
                $value = array_keys(HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($value, $this->em));
            }

            $value = $this->processParameterValue($value);
            $type  = $parameter->getValue() === $value
                ? $parameter->getType()
                : ParameterTypeInferer::inferType($value);

            foreach ($paramMappings[$key] as $position) {
                $types[$position] = $type;
            }

            $sqlPositions      = $paramMappings[$key];
            $sqlPositionsCount = count($sqlPositions);

            // optimized multi value sql positions away for now,
            // they are not allowed in DQL anyways.
            $value      = [$value];
            $countValue = count($value);

            for ($i = 0, $l = $sqlPositionsCount; $i < $l; $i++) {
                $sqlParams[$sqlPositions[$i]] = $value[($i % $countValue)];
            }
        }

        if (count($sqlParams) !== count($types)) {
            throw QueryException::parameterTypeMismatch();
        }

        if ($sqlParams) {
            ksort($sqlParams);
            $sqlParams = array_values($sqlParams);

            ksort($types);
            $types = array_values($types);
        }

        return [$sqlParams, $types];
    }