Symfony关联与单个联接列问题

问题描述

我有以下代码定义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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...