1

我有三个实体StockStockDetailCatalogHasStock。这CatalogHasStock是我的映射:

/**
 * @ORM\ManyToOne(targetEntity="StockBundle\Entity\StockDetail")
 * @ORM\JoinColumns(@ORM\JoinColumn(name="product", referencedColumnName="product"),
 *                  @ORM\JoinColumn(name="company", referencedColumnName="company"),
 *                  @ORM\JoinColumn(name="stock_detail", referencedColumnName="id"),
 *                  @ORM\JoinColumn(name="upc", referencedColumnName="upc"),
 *                  @ORM\JoinColumn(name="kcondition", referencedColumnName="kcondition"))
 */
protected $stock;

现在StockDetail这是映射:

  /**
   * @ORM\ManyToOne(targetEntity="StockBundle\Entity\Stock", inversedBy="sdetails")
   * @ORM\JoinColumns(@ORM\JoinColumn(name="product", referencedColumnName="product"),
   *                  @ORM\JoinColumn(name="company", referencedColumnName="company"),
   *                  @ORM\JoinColumn(name="kcondition", referencedColumnName="kcondition"))
   */
  protected $stock;

我需要插入值CatalogHasStock,我这样做:

$catalog_has_stock = new CatalogHasStock ();
$catalog_has_stock->setStock($entityStockDetail);

但我得到这个错误:

注意:未定义索引:/var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php 行 685 中的产品

映射部分有什么问题?

4

1 回答 1

1

尝试使用以下语法:

* @ORM\JoinColumns({
* @ORM\JoinColumn(name="product", referencedColumnName="product"),
* @ORM\JoinColumn(name="company", referencedColumnName="company"),
* @ORM\JoinColumn(name="kcondition", referencedColumnName="kcondition")
* })

等等。好像你忘了{}

于 2013-10-03T20:00:02.963 回答