I was guided by this, and I can't understand what's going wrong.
My entities:
/**
* @ORM\Entity
* @ORM\Table(name="term")
*/
class Term {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="Description", mappedBy="term")
**/
private $description;
//....
}
/**
* @ORM\Entity
* @ORM\Table(name="description")
*/
class Description {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Orm\ManyToOne(targetEntity="term", inversedBy="description")
* @Orm\JoinColumn(name="term_id", referencedColumnName="id")
**/
private $term;
/**
* @ORM\Column(type="string", length=8)
*/
private $normativity;
//...
}
I need to get terms and filter terms descriptions by one of it fields (normativity in example).
I tried this:
$query = $this->getDoctrine()->getEntityManager()
->createQuery("
SELECT term, desc FROM myTerminologyBundle:Term term
JOIN term.description desc
WHERE term.word LIKE :r_word' and desc.normativity IN :norm"
)->setParameter('r_word', '%'.$word.'%')->setParameter('norm', array());
and I get the following exceptions:
[Syntax Error] line 0, col 30: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got 'desc'