我昨天遇到这种问题,我解决了
https://openclassrooms.com/forum/sujet/erreur-missing-value-for-primary-key
问题又回来了,但是这次我不知道会发生什么:
我在symfony 3.4中
实体在主键级别上处于自动增量状态
我遇到以下错误:
未捕获的PHP异常原则\ Common \ Proxy \ Exception \ OutOfBoundsException:“ Lea \ PrestaBundle \ Entity \ EgwAddressbook上的主键contactId缺少值”
我的实体:
<?php
namespace Lea\PrestaBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Lea\PrestaBundle\Entity\EgwAddressbook
*
* @ORM\Table(name="egw_addressbook")
* @ORM\Entity(repositoryClass="Lea\PrestaBundle\Entity\EgwAddressbookRepository")
*/
class EgwAddressbook
{
/**
* @var integer $contactId
*
* @ORM\Column(name="contact_id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $contactId;
/**
* @var string $contactTid
*
* @ORM\Column(name="contact_tid", type="string", length=1, nullable=true)
*/
private $contactTid;
/**
* @var integer $contactOwner
*
* @ORM\Column(name="contact_owner", type="bigint", nullable=false)
*/
private $contactOwner;
/**
ETC ETC ...
...
This entity EgwAdressBook is linked with the entity EgwPrestation :
/**
* @ORM\ManyToOne(targetEntity="EgwAddressbook", inversedBy="prestationsP")
* @ORM\JoinColumn(name="id_contact_prescripteur", referencedColumnName="contact_id")
*/
private $contactPr;
id_contact_prescripteur和contact_id具有相同的类型(整数)(已经问过的问题)
运行EgwPrestation存储库(以下)时,出现错误消息:
“ Lea \ PrestaBundle \ Entity \ EgwAddressbook上主键contactId的缺失值”
$dql=" SELECT p,pr,ac,t
FROM LeaPrestaBundle:EgwPrestation p
inner join p.prestataire pr
left join p.account ac
left join p.dispositif t
".$sqlPlus."
order by p.dateDebut desc";
return $this->getEntityManager()
->createQuery($dql)
->getResult();
显然是
的执行
return $this->getEntityManager()
->createQuery($dql)
->getResult();
..我有此错误。