我編輯線程放置更多信息。學說多對多關係
我有「用戶」實體和「Rol」實體,我正在努力工作收集用戶的角色。
在我定義的用戶實體:
/**
* @ManyToMany(targetEntity="AppsManantiales\CommonBundle\Entity\Perfil")
* @JoinTable(name="usuarios_perfiles",
* joinColumns={@JoinColumn(name="idUsuario", referencedColumnName="idusuario")},
* inverseJoinColumns={@JoinColumn(name="idPerfil", referencedColumnName="idperfil")}
*)
*/
protected $perfiles;
並在構造函數:
public function __construct(){
$this->perfiles = new \Doctrine\Common\Collections\ArrayCollection();
$this->contacto = new \Doctrine\Common\Collections\ArrayCollection();
}
類的命名空間放前:
use AppsManantiales\CommonBundle\Entity\Perfil;
當執行:
php app/console generate:doctrine:entities CommonBundle
一個錯誤出現:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@ManyToMany" in property AppsManantiales\CommonBundle\Entity\Usuario::$perfiles was never impo
rted. Did you maybe forget to add a "use" statement for this annotation?
任何想法?
ü可以顯示完整的實體代碼?你如何使用mapper? – DaunnC
哦,我已經更新了我的答案。所以它是'Symfony2' :) – DaunnC
檢查@ManyToMany或@ORM \ ManyToMany。這個錯誤似乎是該教義無法找到這個特定的註釋。 – busypeoples