public function findByUniqueAttribute(
        FamilyInterface $family,
        AttributeInterface $attribute,
        $reference,
        $partialLoad = false
    ) {
        if (!$attribute->isUnique()) {
            throw new \LogicException("Cannot find data based on a non-unique attribute '{$attribute->getCode()}'");
        }
        $dataBaseType = $attribute->getType()->getDatabaseType();
        $qb = $this->createQueryBuilder('e');
        $joinCondition = "(identifier.attributeCode = :attributeCode AND identifier.{$dataBaseType} = :reference)";
        $qb
            ->join('e.values', 'identifier', Join::WITH, $joinCondition)
            ->where('e.family = :familyCode')
            ->setParameters(
                [
                    'attributeCode' => $attribute->getCode(),
                    'reference' => $reference,
                    'familyCode' => $family->getCode(),
                ]
            );

        if ($partialLoad) {
            return $this->executeWithPartialLoad($qb);
        }

        return $qb->getQuery()->getOneOrNullResult();
    }