2013-10-03 87 views
0

我有三個實體Stock,StockDetailCatalogHasStock。在CatalogHasStock這是映射我有:如何通過Doctrine2中的另一個關係映射一個關係

/** 
* @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); 

但我得到這個錯誤:

Notice: Undefined index: product in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 685

映射部分有什麼問題?

回答

1

嘗試使用這個語法:

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

等 好像你忘了{}