我的项目中有以下实体结构。
class MyEntity
{
[... some more fields...]
/**
* @Type("array<string, string>")
* @ORM\ManyToMany(targetEntity="Me\MyBundle\Entity\Example")
* @ORM\JoinTable(name="example_myentity",
* joinColumns={@ORM\JoinColumn(name="plan_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="example", referencedColumnName="label")}
* )
*/
private $example;
}
class Example
{
/**
* @ORM\Id
* @ORM\Column(name="label", type="string", length=50, unique=true, nullable=false)
*/
private $label;
}
当我尝试使用 Doctrine 中的 findby() 函数获取“$example”时,我收到以下通知:
未定义索引:joinColumns
我尝试调试了一下,问题似乎出在函数中的学说文件BasicEntityPersister.php中
_getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null),
我在堆栈跟踪中观察到第二个参数 "$assoc" 始终为 null,我认为这就是 Doctrine 不进行 JOIN 语句的原因。
任何想法?
谢谢