php - Can not join in a doctrine query


So I'm trying to do a join in a query but doctrine is doing its usually and throwing back errors that are as useful as a broken leg.

Can anyone advice on where I am going wrong here. The error message I am getting; debug: [Syntax Error] line 0, col -1: Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got end of string. in file "./vendor/symfony/doctrine-bridge/Messenger/DoctrineTransactionMiddleware.php" on line 64

Assessment entity

 * @var Candidate
 * @ORM\ManyToOne(
 *          targetEntity="App\Domain\Candidate\Candidate",
 *          inversedBy="assessments")
 * @ORM\JoinColumn(nullable=false)
private $candidate;

Candidate entity

 * @var Assessment[]|Collection
 * @ORM\OneToMany(
 *      targetEntity="App\Domain\Assessment\Assessment",
 *      mappedBy="candidate",
 *      cascade={"persist"})
 * @ORM\JoinColumn(nullable=false)
private $assessments;

Doctrine query

$qb = $this->entityManager->createQueryBuilder();

    ->from(Candidate::class, 'ca')
    ->innerJoin('ca.assessments', 'as');



You're using an alias in your join which is a reserved keyword (as).

    ->from(Candidate::class, 'ca')
    ->innerJoin('ca.assessments', 'as'); // <-- change this alias

Changeas in your join to something else.

People are also looking for solutions to the problem: php - Symfony Sonata SEO custom sql query with LIKE


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.