实体上的主键ID缺少值

时间:2019-08-29 18:19:06

标签: php symfony frameworks doctrine

我正在尝试返回我的实体,但是当我提出请求时却收到此错误,但我不知道我在这种关系上做错了什么 (1/2)OutOfBoundsException \ ApiBundle \ Entity \ Type

上的主键ID缺少值

我的会话实体:

<?php

namespace Primepass\ApiBundle\Entity;

use Ramsey\Uuid\UuidInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 * Session
 *
 * @ORM\Table(name="session", uniqueConstraints={@ORM\UniqueConstraint(name="session_id_uindex", columns={"id"})})
 * @ORM\Entity(repositoryClass="Primepass\ApiBundle\Repository\SessionRepository")
 */
class Session
{

    /**
     * @var UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
     */
    private $id;

    /**
     * @var Theater
     *
     * @ORM\OneToOne(targetEntity="Theater")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="theater_id", referencedColumnName="id")
     * })
     */
    private $theater;

    /**
     * @var Movie
     *
     * @ORM\OneToOne(targetEntity="Movie")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="movie_id", referencedColumnName="id")
     * })
     */
    private $movie;

    /**
     * @var Type
     *
     * @ORM\OneToOne(targetEntity="Type")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="audio_type", referencedColumnName="type_name")
     * })
     */
    private $audioType;

    /**
     * @var Type
     *
     * @ORM\OneToOne(targetEntity="Type")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="screen_type", referencedColumnName="type_name")
     * })
     */
    private $screenType;

    /**
     * @var Type
     *
     * @ORM\OneToOne(targetEntity="Type")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="room_type", referencedColumnName="type_name")
     * })
     */
    private $roomType;

    /**
     * @var string
     *
     * @ORM\Column(name="room_name",type="string")
     */
    private $roomName;

    /**
     * @var int
     *
     * @ORM\Column(name="price", type="integer", nullable=false)
     */
    private $price;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="date", type="datetime", nullable=false)
     */
    private $date;

    /**
     * @var \Time
     *
     * @ORM\Column(name="hour", type="time", nullable=false)
     */
    private $hour;

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

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="created_at", type="datetime", nullable=false, options={"default"="2001-01-01 00:00:00"})
     */
    private $createdAt = '2001-01-01 00:00:00';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="updated_at", type="datetime", nullable=false, options={"default"="2001-01-01 00:00:00"})
     */
    private $updatedAt = '2001-01-01 00:00:00';

    public function getId(): UuidInterface
    {
        return $this->id;
    }

    public function getTheater(): ?Theater
    {
        return $this->theater;
    }

    public function setTheater(?Theater $theater): self
    {
        $this->theater = $theater;

        return $this;
    }

    public function getMovie(): ?Movie
    {
        return $this->movie;
    }

    public function setMovie(?Movie $movie): self
    {
        $this->movie = $movie;

        return $this;
    }

    public function getAudioType(): ?Type
    {
        return $this->audioType;
    }

    public function setAudioType(?Type $audioType): self
    {
        $this->audioType = $audioType;

        return $this;
    }

    public function getScreenType(): ?Type
    {
        return $this->screenType;
    }

    public function setScreenType(?Type $screenType): self
    {
        $this->screenType = $screenType;

        return $this;
    }

    public function getRoomType(): ?Type
    {
        return $this->roomType;
    }

    public function setRoomType(?Type $roomType): self
    {
        $this->roomType = $roomType;

        return $this;
    }

    public function getRoomName(): ?string
    {
        return $this->roomName;
    }

    public function setRoomName($roomName): self
    {
        $this->roomName = $roomName;

        return $this;
    }

    public function getPrice(): ?int
    {
        return $this->price;
    }

    public function setPrice(?int $price): self
    {
        $this->price = $price;

        return $this;
    }

    public function getDate(): ?\DateTimeInterface
    {
        return $this->date;
    }

    public function setDate(\DateTimeInterface $date): self
    {
        $this->date = $date;

        return $this;
    }

    public function getHour(): ?\Time
    {
        return $this->hour;
    }

    public function setHour(\Time $hour): self
    {
        $this->hour = $hour;

        return $this;
    }

    public function getIsActive(): bool
    {
        return $this->isActive;
    }

    public function setIsActive(bool $isActive): self
    {
        $this->isActive = $isActive;

        return $this;
    }

    public function getCreatedAt(): ?\DateTimeInterface
    {
        return $this->createdAt;
    }

    public function setCreatedAt(\DateTimeInterface $createdAt): self
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    public function getUpdatedAt(): ?\DateTimeInterface
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt(\DateTimeInterface $updatedAt): self
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

}


类型实体:

<?php

namespace Primepass\ApiBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Ramsey\Uuid\UuidInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 * Type
 *
 * @ORM\Table(name="type")
 * @ORM\Entity(repositoryClass="Primepass\ApiBundle\Repository\TypeRepository")
 */
class Type
{
    /**
     * @var UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
     */
    private $id;

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

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

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="created_at", type="datetime", nullable=false, options={"default"="2001-01-01 00:00:00"})
     */
    private $createdAt = '2001-01-01 00:00:00';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="updated_at", type="datetime", nullable=false, options={"default"="2001-01-01 00:00:00"})
     */
    private $updatedAt = '2001-01-01 00:00:00';

    /**
     * @ORM\ManyToMany(targetEntity="TicketRules", mappedBy="types")
     * @ORM\JoinTable(name="ticket_rules_type")
     */
    private $ticketRuleScreens;

    public function __construct()
    {
        $this->ticketRuleScreens = new ArrayCollection();
    }

    public function getId(): UuidInterface
    {
        return $this->id;
    }

    public function getTypeName(): string
    {
        return $this->typeName;
    }

    public function setTypeName(string $typeName): self
    {
        $this->typeName = $typeName;

        return $this;
    }

    public function getTypeInfo(): string
    {
        return $this->typeInfo;
    }

    public function setTypeInfo(string $typeInfo): self
    {
        $this->typeInfo = $typeInfo;

        return $this;
    }

    public function getCreatedAt(): \DateTimeInterface
    {
        return $this->createdAt;
    }

    public function setCreatedAt(\DateTimeInterface $createdAt): self
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    public function getUpdatedAt(): \DateTimeInterface
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt(\DateTimeInterface $updatedAt): self
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    public function getTicketRuleScreens()
    {
        return $this->ticketRuleScreens;
    }

    public function setTicketRuleScreens($ticketRuleScreens): self
    {
        $this->ticketRuleScreens = $ticketRuleScreens;

        return $this;
    }
}


我期望带有分页器的json返回,但会话模型有问题

0 个答案:

没有答案