我编辑线程以获取更多信息。
我有“用户”实体和“角色”实体,我正在努力收集用户的角色。
在我定义的用户实体中:
/**
* @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?
有任何想法吗 ?。