有我的问题,我需要显示所有没有相关客户的联系人。 我的dql是:
SELECT c FROM ComercialBundle:Contacto c WHERE c.cliente IS NULL
我收到了下一个错误:
A single-valued association path expression to an inverse side is not supported in DQL queries. Use an explicit join instead.
实体关联:
Contacto.php
/**
* @ORM\OneToOne(targetEntity="CeiferIT\ComercialBundle\Entity\Cliente", mappedBy="contacto", cascade={"persist", "remove"})
**/
private $cliente;
Cliente.php
/**
* @ORM\OneToOne(targetEntity="CeiferIT\ComercialBundle\Entity\Contacto", inversedBy="cliente", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="contacto_id", referencedColumnName="id")
**/
private $contacto;
我应该如何创建DQL?
感谢!
答案 0 :(得分:1)
我给你SQL查询,你很容易就可以制作DQL。
select c.* from Contacto c
LEFT JOIN Cliente cc on cc.contacto_id = c.id
where cc.id is null
希望这对你有所帮助。