我有一个项目,其中在同一个数据库中具有OneToMany关系。
目前的设计如下:
/**
* @ORM\OneToMany(targetEntity="MyEntity", mappedBy="myCopiedItem")
*/
protected $mySource;
/**
* @ORM\ManyToOne(targetEntity="MyEntity", inversedBy="mySource")
* @ORM\JoinColumn(name="selected_myentity_copy_id", referencedColumnName="id")
*/
protected $myCopiedItem;
但现在我必须将这个关系改为ManyToMany。所以我做了以下操作:
/**
* @ORM\ManyToMany(targetEntity="MyEntity", mappedBy="myCopiedItem")
*/
protected $mySource;
/**
* @ORM\ManyToMany(targetEntity="MyEntity", inversedBy="mySource")
* @ORM\JoinTable(name="entity_has_copy")
*/
protected $myCopiedItem;
但Symfony创建的“entity_has_copy”表只有一个项目(myentity_id),我希望有两个字段“myentity_id”和“selected_myentity_copy_id”,它们都是来自我的“myentity”表的实际id...
我需要修改什么才能在生成的表中拥有这两个id?
我确信我漏掉了什么,但我无法弄清楚是什么 :(
注:为保护隐私,实体/表名称已更改。