I have a problem with join in Symfony Doctrine.
I have a master Entity:
class PosterCartelli{
...
/**
* @var int|null
*
* @ORM\Column(name="id_poster_categoria", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="App\Entity\PosterCategorie", inversedBy="idPosterCategoria")
* @JoinColumn(name="id_poster_categoria", referencedColumnName="id_poster_categoria")
*/
private $idPosterCategoria;
...
}
And join with this Entity:
class PosterCategorie{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(name="id_poster_categoria", type="integer")
* @ORM\OneToMany(targetEntity="App\Entity\PosterCartelli", mappedBy="idPosterCategoria")
*/
private $idPosterCategoria;
...
}
My Select in PosterCartelliRepository is:
return $this->createQueryBuilder('pc')
->andWhere('pc.stato = \'Y\'')
->join('pc.idPosterCategoria', 'ipc')
->orderBy('pc.numeroCartello', 'ASC')
->getQuery()
->getResult();
But I have always the same error: [Semantical Error] line 0, col 76 near 'ipc WHERE pc.stato': Error: Class App\Entity\PosterCartelli has no association named idPosterCategoria
I tried in different way but I don't have success. I think that everything is correct, because PosterCartelli.idPosterCagoria is declare ManyToOne with "IdPosterCategory" and viceversa.
Can anyone help me, please?