我遇到了教义查询生成器的问题,向我抛出 [语义错误] 我正在尝试构建的查询是这样的:-
$query = $this->_em->createQueryBuilder()
->select('r, m')
->from('Ajfit\Entity\TicketReply', 'r')
->join('r.mailFk', 'm')
->where('r.ticketFk = :ticket')
->orderBy('m.dt', 'desc')
->setParameter('ticket', $ticket)
->getQuery();
$paginator = new Paginator($query);
return $paginator->getIterator(); //////////blows up here!
抛出的错误是:-
[Semantical Error] line 0, col 64 near 'm WHERE r.ticketFk': Error: Class Ajfit\Entity\TicketReply has no association named mailFk
错误所指的实体是:-
命名空间 Ajfit\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Ajfit\Entity\TicketReply
*
* @ORM\Table(name="ticket_reply")
* @ORM\Entity(repositoryClass="Ajfit\Repository\TicketReply")
* @ORM\HasLifecycleCallbacks
*/
class TicketReply extends \Doctrine\Common\Persistence\PersistentObject
{
/**
* @ORM\Id
* @ORM\Column(name="mail_fk", type="integer")
* @ORM\ManyToOne(targetEntity="Ajfit\Entity\Mail", inversedBy="replies")
* @ORM\JoinColumn(name="mail_fk", referencedColumnName="pk")
*/
protected $mailFk;
/**
* @ORM\Id
* @ORM\Column(name="ticket_fk", type="integer")
* @ORM\ManyToOne(targetEntity="Ajfit\Entity\Ticket", inversedBy="replies")
* @ORM\JoinColumn(name="ticket_fk", referencedColumnName="pk")
*/
protected $ticketFk;
/**
* @var integer $rating
*
* @ORM\Column(name="rating", type="integer")
*/
protected $rating;
}
由于 TicketReply 实体没有 mailFk 关联的错误详细信息,但是它确实存在,我编写查询构建器的原因是否存在问题?
谢谢安德鲁