public function reverseTransform($value)
    {
        if ('' === $value || null === $value) {
            return null;
        }

        if (!is_scalar($value)) {
            throw new TransformationFailedException('Value is not scalar');
        }

        try {
            $hash = $this->getCacheHash($value);
            if (array_key_exists($hash, $this->cachedResults)) {
                $entity = $this->cachedResults[$hash];
            } else {
                //Result not in cache

                $alias = current($this->queryBuilder->getRootAliases());
                $query = $this->queryBuilder->andWhere(
                    sprintf('%s.%s = :key_transformer', $alias, $this->identifier)
                )
                    ->setParameter('key_transformer', $value)
                    ->getQuery();

                $entity = $query->getSingleResult();
                $this->cachedResults[$hash] = $entity; //Saves result in cache
            }
        } catch (\Exception $e) {
            if ($this->throwExceptionIfValueNotFoundInReverse) {
                throw new TransformationFailedException(
                    sprintf('The entity with key "%s" could not be found or is not unique', $value)
                );
            } else {
                return null;
            }
        }

        return $entity;
    }