Created
April 12, 2012 17:08
-
-
Save jmolivas/2369209 to your computer and use it in GitHub Desktop.
ManyToMany - Undefined index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-User entity: | |
/** | |
* Owning Side | |
* | |
* @ORM\ManyToMany(targetEntity="Company\MyBundle\Entity\Team", inversedBy="users") | |
* @ORM\JoinTable(name="user_team", | |
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, | |
* inverseJoinColumns={@JoinColumn(name="team_id", referencedColumnName="id")} | |
* ) | |
* | |
* @var ArrayCollection $teams | |
*/ | |
private $teams; | |
-Team entity: | |
/** | |
* Inverse Side | |
* | |
* @ORM\ManyToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="teams") | |
* @var ArrayCollection $users | |
*/ | |
private $users; |
Gracias ya encontre el error, era una configuración en un XML User.orm.xml ya que estoy utilizando un FOSBundle y estoy haciendo la referencia en una entidad de ese bundle Application\Sonata\UserBundle\Entity\User
El nombre de la tabla quedo como user_team ya que la entidad User es la establecida como "Owning Side"
Finalmente termine reemplazando esta relación many-to-many por dos many-to-one
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No entiendo mucho de lo que veo, pero si de algo sirve... en rails por ejemplo, los many-to-many se definen alfabéticamente, por lo que tu tabla (en rails) se llamaría team_users, ambos campos user_id y team_id tendrían un index compuesto. Hope it helps.