No identifier specified error Symfony2 Doctrine ORM mapping

Einius

When I try to run php app/config doctrine:schema:update --force or just symply open my project in the web browser I get this error:

MappingException: No identifier/primary key specified for Entity "Registration\BusinessBundle\Entity\BusinessUser". Every Entity must have an identifier/primary key.

Manually deleted the app/cache folder but the problem remained. If I try to delete cache via command php app/console cache:clear I get the same error.

BusinessUser Entity:

<?php
namespace Registration\BusinessBundle\Entity;

//use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="business_user")
 */
class BusinessUser
{
    /*
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /*
     * @ORM\Column(type="string", length=255)
     */
    protected $surname;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set surname
     *
     * @param string $surname
     * @return BusinessUser
     */
    public function setSurname($surname)
    {
        $this->surname = $surname;

        return $this;
    }
    /**
     * Get surname
     *
     * @return string
     */
    public function getSurname()
    {
        return $this->surname;
    }
}
SenseException

Your Entity does not contain PHP docblock comments where your Doctrine Annotation is used.

Docblocks are startet with two asterisks, otherwise it's just a simple comment.

Change your current code

/*
 * @ORM\Id
 * @ORM\Column(type="integer") 
 * @ORM\GeneratedValue(strategy="AUTO") 
 */
protected $id;

to

/**
 * @ORM\Id
 * @ORM\Column(type="integer") 
 * @ORM\GeneratedValue(strategy="AUTO") 
 */
protected $id;

Only with /** will annotations be recognized by Doctrine.

Check your other properties too.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony2 Doctrine: syntax error, unexpected 'function', expecting 'identifier'

From Dev

Doctrine2 @ORM in entity mapping annotation

From Dev

Sql convert to orm doctrine Symfony2

From Dev

Doctrine Mapping in Symfony2 using YAML

From Dev

Mapping entities in XML at Symfony2 + Doctrine

From Dev

Symfony2 Doctrine one to one mapping

From Dev

Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got '*'

From Dev

Doctrine: No identifier/primary key specified for

From Dev

symfony2 & doctrine orderBy/DQL error

From Dev

Symfony2, Doctrine2, Entity Mapping

From Dev

Doctrine2 YML Mapping on Symfony2

From Dev

Symfony2, Doctrine2, Entity Mapping

From Dev

Invalidating doctrine ORM cache in a rabbitmq-consumer | Symfony2

From Dev

Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

From Dev

Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

From Dev

Symfony2 Doctrine ORM cascade detach not working

From Dev

Symfony Form Error: "Expected argument of type "Doctrine\ORM\QueryBuilder", "Doctrine\ORM\Query" given"

From Dev

Symfony Form Error: "Expected argument of type "Doctrine\ORM\QueryBuilder", "Doctrine\ORM\Query" given"

From Dev

Codeigniter 3 with Doctrine 2 - Doctrine\ORM\Mapping\MappingException Class is not a valid entity or mapped super class

From Dev

Change Doctrine ORM mapping from XML to Annotations

From Dev

symfony2 doctrine2 batch processing error with entity

From Dev

Query with Criteria Exception error in doctrine2,Symfony2

From Dev

symfony2 doctrine2 batch processing error with entity

From Dev

Error when use custom DQL function with Doctrine and Symfony2

From Dev

Doctrine error when deploying symfony2 app on pagoda box

From Dev

Symfony2 - Doctrine query for finding posts by slug has an error

From Dev

Symfony2 - Doctrine query for finding posts by slug has an error

From Dev

Symfony2 Doctrine ORM Manager named “db2” does not exist

From Dev

Cascaded persist not working (Doctrine ORM + Symfony 2)

Related Related

  1. 1

    Symfony2 Doctrine: syntax error, unexpected 'function', expecting 'identifier'

  2. 2

    Doctrine2 @ORM in entity mapping annotation

  3. 3

    Sql convert to orm doctrine Symfony2

  4. 4

    Doctrine Mapping in Symfony2 using YAML

  5. 5

    Mapping entities in XML at Symfony2 + Doctrine

  6. 6

    Symfony2 Doctrine one to one mapping

  7. 7

    Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got '*'

  8. 8

    Doctrine: No identifier/primary key specified for

  9. 9

    symfony2 & doctrine orderBy/DQL error

  10. 10

    Symfony2, Doctrine2, Entity Mapping

  11. 11

    Doctrine2 YML Mapping on Symfony2

  12. 12

    Symfony2, Doctrine2, Entity Mapping

  13. 13

    Invalidating doctrine ORM cache in a rabbitmq-consumer | Symfony2

  14. 14

    Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

  15. 15

    Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

  16. 16

    Symfony2 Doctrine ORM cascade detach not working

  17. 17

    Symfony Form Error: "Expected argument of type "Doctrine\ORM\QueryBuilder", "Doctrine\ORM\Query" given"

  18. 18

    Symfony Form Error: "Expected argument of type "Doctrine\ORM\QueryBuilder", "Doctrine\ORM\Query" given"

  19. 19

    Codeigniter 3 with Doctrine 2 - Doctrine\ORM\Mapping\MappingException Class is not a valid entity or mapped super class

  20. 20

    Change Doctrine ORM mapping from XML to Annotations

  21. 21

    symfony2 doctrine2 batch processing error with entity

  22. 22

    Query with Criteria Exception error in doctrine2,Symfony2

  23. 23

    symfony2 doctrine2 batch processing error with entity

  24. 24

    Error when use custom DQL function with Doctrine and Symfony2

  25. 25

    Doctrine error when deploying symfony2 app on pagoda box

  26. 26

    Symfony2 - Doctrine query for finding posts by slug has an error

  27. 27

    Symfony2 - Doctrine query for finding posts by slug has an error

  28. 28

    Symfony2 Doctrine ORM Manager named “db2” does not exist

  29. 29

    Cascaded persist not working (Doctrine ORM + Symfony 2)

HotTag

Archive