【发布时间】:2017-10-27 19:11:42
【问题描述】:
我有两个实体 Export 和 ExportItem。导出实体中的一列是config json 类型(这是我数据库中唯一具有 json 类型的列)。
部分出口实体:
/**
* @ORM\Column(type="json", nullable=true)
*/
protected $config;
/**
* @var ArrayCollection|ExportItem[]
* @ORM\OneToMany(targetEntity="Entity\ExportItem", mappedBy="export", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
*/
protected $items;
ExportItem 实体的一部分:
/**
* @var Export
* @ORM\ManyToOne(targetEntity="Entity\Export", inversedBy="items")
*/
protected $export;
我想按附加的 ExportItems 数量订购 Exports,但下一个查询抛出错误“无法识别 json 类型的相等运算符”
$this->createQueryBuilder('o')
->join('o.suit', 's')
->where('s.id = :suitId')
->setParameter('suitId', $suit->getId())
->select('COUNT(i) AS HIDDEN nbrItems', 'o.id')
->leftJoin('o.items', 'i')
->orderBy('nbrItems', $orderDir)
->groupBy('o');
【问题讨论】: