我编辑线程放置更多信息。学说多对多关系
我有“用户”实体和“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