问题描述
我有以下代码定义2个实体之间的关系:
/**
* Barcode
*
* @ORM\Table(name="barcode")
* @ORM\Entity
*/
class Barcode
{
.
.
.
/**
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="Entity\Product",cascade={"persist"},mappedBy="barcodes")
*/
protected $products;
.
.
.
/**
* Barcode constructor.
*/
function __construct()
{
$this->products = new ArrayCollection();
}
和
/**
* Product
*/
class Product implements DoctrineTranslatable
{
.
.
.
/**
* @var Collection
*/
protected $barcodes;
.
.
.
public function __construct()
{
$this->barcodes = new ArrayCollection();
}
具有在xml文件中定义的关系:
<many-to-many field="barcodes" target-entity="Entity\Barcode"
inversed-by="products" index-by="products" fetch="LAZY">
<cascade>
<cascade-persist/>
</cascade>
<join-table name="products_barcodes">
<join-columns>
<join-column name="product_id" referenced-column-name="id"/>
</join-columns>
<inverse-join-columns>
<join-column name="barcode_id" referenced-column-name="id" nullable="1"/>
</inverse-join-columns>
</join-table>
</many-to-many>
执行任何查询时,出现以下错误: “ Entity \ Barcode#products”与单个连接列无关。
可能是什么问题?
注意:将商品添加到需要query_builder属性的产品类的表单中时发现了问题
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)