В настоящее время я пытаюсь создать простой запрос для поиска пользователя по его имени:
namespace Swenso\IntranetBundle\Repository;
use Swenso\IntranetBundle\Entity\Employee;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method Employee|null find($id, $lockMode = null, $lockVersion = null)
* @method Employee|null findOneBy(array $criteria, array $orderBy = null)
* @method Employee[] findAll()
* @method Employee[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class EmployeeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Employee::class);
}
public function findByUsername($value)
{
return $this->createQueryBuilder('e')
->andWhere('e.username = :val')
->setParameter('val', $value)
->orderBy('e.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
Запуск этого кода приводит к следующей ошибке:
Attempted to load class "Composite" from namespace "Doctrine\ORM\Query\Expr".
Did you forget a "use" statement for "Symfony\Component\Validator\Constraints\Composite"?
Если я уйду andWhere()
запрос выполняется хорошо ...
Если бы кто-то мог помочь нам, это было бы здорово!
BR wucherpfennig