I have two netities user & service and the join table user_service generated by doctrine, i tried to add a manytomany relatioship here is the annotations that i added :
Entity User side :
/**
* @ORM\ManyToMany(targetEntity="Service", inversedBy="users")
* @ORM\JoinTable(name="user_service",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="service_id", referencedColumnName="id")}
* )
*/
protected $services;
Entity Service side :
/**
* @ORM\ManyToMany(targetEntity="User", mappedBy="services")
*/
protected $users;
Everything seems to work fine, but when i make this request :
$query = $em->createQuery(
'SELECT u
FROM ApplicationFrontBundle:User u
JOIN u.service s
WHERE u.id = :id
'
)->setParameters(array('id'=> $id));
$services = $query->getArrayResult();
I have this error :
[Semantical Error] line 0, col 91 near 's
': Error: Class Application\FrontBundle\Entity\User has no association named service
But when i do it by the objects it works, the problem is that it executes a lot of requests