Every Entity must have an identifier/primary key. #5454

Closed
opened 2026-01-22 15:08:08 +01:00 by admin · 2 comments
Owner

Originally created by @klausbreyer on GitHub (Mar 13, 2017).

Originally assigned to: @Ocramius on GitHub.

Hi,

I am experiencing the following error:

$ php vendor/bin/doctrine orm:info
Found 1 mapped entities:
[FAIL] Entity\Channel
No identifier/primary key specified for Entity "Entity\Channel". Every Entity must have an identifier/primary key.

This is the Channel.php

<?php

namespace Entity;

/** @Entity */
class Channel
{
    /*
     * @Id
     * @Column(type="integer", nullable=false)
     * @GeneratedValue(strategy="AUTO")
     */
    private $id;

    /** @Column(type="integer") */
    private $channelId;

    /** @Column(type="integer") */
    private $type;

    /** @Column(type="datetime") */
    private $createdAt;

    /** @Column(type="datetime") */
    private $updatedAtInput;

    /** @Column(type="datetime") */
    private $updatedAtProcessed;

    /** @Column(type="json_array") */
    private $channelContent;

    /** @Column(type="json_array") */
    private $processingOutput;


    public function __construct()
    {
        $this->createdAt = new \DateTime('now');
    }


    /**
     * Set channelId
     *
     * @param integer $channelId
     *
     * @return Channel
     */
    public function setChannelId($channelId)
    {
        $this->channelId = $channelId;

        return $this;
    }

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

    /**
     * Set type
     *
     * @param integer $type
     *
     * @return Channel
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

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

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return Channel
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedAtInput
     *
     * @param \DateTime $updatedAtInput
     *
     * @return Channel
     */
    public function setUpdatedAtInput($updatedAtInput)
    {
        $this->updatedAtInput = $updatedAtInput;

        return $this;
    }

    /**
     * Get updatedAtInput
     *
     * @return \DateTime
     */
    public function getUpdatedAtInput()
    {
        return $this->updatedAtInput;
    }

    /**
     * Set updatedAtProcessed
     *
     * @param \DateTime $updatedAtProcessed
     *
     * @return Channel
     */
    public function setUpdatedAtProcessed($updatedAtProcessed)
    {
        $this->updatedAtProcessed = $updatedAtProcessed;

        return $this;
    }

    /**
     * Get updatedAtProcessed
     *
     * @return \DateTime
     */
    public function getUpdatedAtProcessed()
    {
        return $this->updatedAtProcessed;
    }

    /**
     * Set channelContent
     *
     * @param array $channelContent
     *
     * @return Channel
     */
    public function setChannelContent($channelContent)
    {
        $this->channelContent = $channelContent;

        return $this;
    }

    /**
     * Get channelContent
     *
     * @return array
     */
    public function getChannelContent()
    {
        return $this->channelContent;
    }

    /**
     * Set processingOutput
     *
     * @param array $processingOutput
     *
     * @return Channel
     */
    public function setProcessingOutput($processingOutput)
    {
        $this->processingOutput = $processingOutput;

        return $this;
    }

    /**
     * Get processingOutput
     *
     * @return array
     */
    public function getProcessingOutput()
    {
        return $this->processingOutput;
    }
}

Here is my full repository: https://github.com/klausbreyer/debug-doctrine

I am totally puzzled why this is happening. Also did a the following to clear the cache:

 php vendor/bin/doctrine orm:clear-cache:metadata
Originally created by @klausbreyer on GitHub (Mar 13, 2017). Originally assigned to: @Ocramius on GitHub. Hi, I am experiencing the following error: ``` $ php vendor/bin/doctrine orm:info Found 1 mapped entities: [FAIL] Entity\Channel No identifier/primary key specified for Entity "Entity\Channel". Every Entity must have an identifier/primary key. ``` This is the Channel.php ``` <?php namespace Entity; /** @Entity */ class Channel { /* * @Id * @Column(type="integer", nullable=false) * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="integer") */ private $channelId; /** @Column(type="integer") */ private $type; /** @Column(type="datetime") */ private $createdAt; /** @Column(type="datetime") */ private $updatedAtInput; /** @Column(type="datetime") */ private $updatedAtProcessed; /** @Column(type="json_array") */ private $channelContent; /** @Column(type="json_array") */ private $processingOutput; public function __construct() { $this->createdAt = new \DateTime('now'); } /** * Set channelId * * @param integer $channelId * * @return Channel */ public function setChannelId($channelId) { $this->channelId = $channelId; return $this; } /** * Get channelId * * @return integer */ public function getChannelId() { return $this->channelId; } /** * Set type * * @param integer $type * * @return Channel */ public function setType($type) { $this->type = $type; return $this; } /** * Get type * * @return integer */ public function getType() { return $this->type; } /** * Set createdAt * * @param \DateTime $createdAt * * @return Channel */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set updatedAtInput * * @param \DateTime $updatedAtInput * * @return Channel */ public function setUpdatedAtInput($updatedAtInput) { $this->updatedAtInput = $updatedAtInput; return $this; } /** * Get updatedAtInput * * @return \DateTime */ public function getUpdatedAtInput() { return $this->updatedAtInput; } /** * Set updatedAtProcessed * * @param \DateTime $updatedAtProcessed * * @return Channel */ public function setUpdatedAtProcessed($updatedAtProcessed) { $this->updatedAtProcessed = $updatedAtProcessed; return $this; } /** * Get updatedAtProcessed * * @return \DateTime */ public function getUpdatedAtProcessed() { return $this->updatedAtProcessed; } /** * Set channelContent * * @param array $channelContent * * @return Channel */ public function setChannelContent($channelContent) { $this->channelContent = $channelContent; return $this; } /** * Get channelContent * * @return array */ public function getChannelContent() { return $this->channelContent; } /** * Set processingOutput * * @param array $processingOutput * * @return Channel */ public function setProcessingOutput($processingOutput) { $this->processingOutput = $processingOutput; return $this; } /** * Get processingOutput * * @return array */ public function getProcessingOutput() { return $this->processingOutput; } } ``` Here is my full repository: https://github.com/klausbreyer/debug-doctrine I am totally puzzled why this is happening. Also did a the following to clear the cache: ``` php vendor/bin/doctrine orm:clear-cache:metadata ```
admin added the BugInvalid labels 2026-01-22 15:08:08 +01:00
admin closed this issue 2026-01-22 15:08:08 +01:00
Author
Owner

@Ocramius commented on GitHub (Mar 13, 2017):

A docblock has to start with /**, your comment starts with /*.

@Ocramius commented on GitHub (Mar 13, 2017): A docblock has to start with `/**`, your comment starts with `/*`.
Author
Owner

@klausbreyer commented on GitHub (Mar 13, 2017):

bummer..t hanks!

@klausbreyer commented on GitHub (Mar 13, 2017): bummer..t hanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5454