DoctrineORM - > OutOfBoundsException - >缺少主键ID

时间:2017-04-06 08:47:37

标签: php codeigniter doctrine-orm doctrine

我正在使用Doctrine ORM和CodeIgniter。错误看起来像这样;

  

遇到未捕获的异常

     

键入:Doctrine \ Common \ Proxy \ Exception \ OutOfBoundsException

  消息:TestDoor

上缺少主键ID的值   文件名:> /home/qualesof/hotel.qualesoft.com/application/libraries/Doctrine/Common/Proxy/Exception/OutOfBoundsException.php

  行号:40

Class TestRoom

<?php

require_once(APPPATH . "models/Entities/TestDoor.php");

use Doctrine\ORM\Mapping as ORM;

/**
 * TestRoom
 *
 * @ORM\Table(name="test_room", indexes={@ORM\Index(name="test_door_code", columns={"test_door_code"})})
 * @ORM\Entity
 */
class TestRoom implements JsonSerializable
{
    public function jsonSerialize()
    {
        return get_object_vars($this);
    }
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
     */
    private $name;

    /**
     * @var \TestDoor
     *
     * @ORM\ManyToOne(targetEntity="TestDoor")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="test_door_code", referencedColumnName="code")
     * })
     */
    private $testDoorCode;


    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return TestRoom
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set testDoorCode
     *
     * @param \TestDoor $testDoorCode
     *
     * @return TestRoom
     */
    public function setTestDoorCode(\TestDoor $testDoorCode = null)
    {
        $this->testDoorCode = $testDoorCode;

        return $this;
    }

    /**
     * Get testDoorCode
     *
     * @return \TestDoor
     */
    public function getTestDoorCode()
    {
        return $this->testDoorCode;
    }
}

Class TestDoor

<?php

use Doctrine\ORM\Mapping as ORM;

/**
 * TestDoor
 *
 * @ORM\Table(name="test_door", uniqueConstraints={@ORM\UniqueConstraint(name="code", columns={"code"})})
 * @ORM\Entity
 */
class TestDoor implements JsonSerializable
{
    public function jsonSerialize()
    {
        return get_object_vars($this);
    }
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="code", type="string", length=3, nullable=false)
     */
    private $code;

    /**
     * @var boolean
     *
     * @ORM\Column(name="all_included", type="boolean", nullable=false)
     */
    private $allIncluded;


    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set code
     *
     * @param string $code
     *
     * @return TestDoor
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get code
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set allIncluded
     *
     * @param boolean $allIncluded
     *
     * @return TestDoor
     */
    public function setAllIncluded($allIncluded)
    {
        $this->allIncluded = $allIncluded;

        return $this;
    }

    /**
     * Get allIncluded
     *
     * @return boolean
     */
    public function getAllIncluded()
    {
        return $this->allIncluded;
    }
}

0 个答案:

没有答案