How can I use a different namespace class in Doctrine2 targetEntity mapping
doctrine-orm
Solution
You have to use the absolute namespace of your target entity - note the leading backspace in its name.
/**
* @ORM\ManyToOne(targetEntity="\OP\ProjectBundle\Entity\Project", inversedBy="tickets")
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
*/
protected $project;
Problem
When I set a ManytoOne mapping, while both class in same namespace, it works. but it won't work if the two class are in different namespace? ``` /** * @ORM\ManyToOne(targetEntity="OP\ProjectBundle\Entity\Project", inversedBy="tickets") * @ORM\JoinColumn(name="project_id", referencedColumnName="id") */ protected $project; ```