Doctrine从集合中删除项目 - 不同的列名称

时间:2017-12-19 10:55:36

标签: doctrine-orm

我对Doctrine集合有疑问。在 PromoCodeTerm 实体中我有@OneToMany $days集合,但是当doctrine从此集合中删除项目时,生成具有不同列名的SQL查询,如 promoCodeTerm 而不是 promo_code_term_id

class PromoCodeTerm {

    /**
     * @var string
     * @ORM\Column(name="id", type="guid")
     * @ORM\Id()
     */
    private $id;

    /**
     * @var PromoCodeTermDay[]
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\PromoCode\PromoCodeTermDay", mappedBy="promoCodeTerm", cascade={"persist"}, orphanRemoval=true)
     */
    private $days;
}

class PromoCodeTermDay {

    /**
     * @var integer
     * @ORM\Column(name="day_id", type="integer")
     * @ORM\Id()
     */
    private $day;

    /**
     * @var PromoCodeTerm
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PromoCode\PromoCodeTerm", inversedBy="days")
     * @ORM\JoinColumn(name="promo_code_term_id", referencedColumnName="id", onDelete="CASCADE")
     * @ORM\Id()
     */
    private $promoCodeTerm;
}

我做错了什么?

An exception occurred while executing 'DELETE FROM `promo_code__promo_code_term_day` WHERE `day` = ? AND `promoCodeTerm` = ?' with params [1, \"c2fce03a-0507-47ca-a060-362cce683b06\"]:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'promoCodeTerm' in 'where clause'

0 个答案:

没有答案