public function findPageByBusinessEntityAndPattern(BusinessTemplate $pattern, $entity, BusinessEntity $businessEntity)
    {
        if (is_object($entity)) {
            $entity = $entity->getId();
        }
        $qb = $this->createQueryBuilder('BusinessPage');
        $qb->join('BusinessPage.entityProxy', 'proxy');
        $qb->join('BusinessPage.template', 'template');
        $qb->join('proxy.'.$businessEntity->getId(), 'entity');

        $qb->where('template.id = :templateId');

        $qb->andWhere('entity.id = :entityId');

        $qb->setParameter(':templateId', $pattern);
        $qb->setParameter(':entityId', $entity);
        $result = $qb->getQuery()->getOneOrNullResult();

        return $result;
    }