3

I've changed the primary key of an entity, but now I'm getting back this error:

ReflectionException Property DnD\\ApiBundle\\Entity\\Agent::$id does not exist

My entity is this:

<?php

namespace DnD\ApiBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;

/**
 * Agent
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="DnD\ApiBundle\Repository\AgentRepository")
 */
class Agent
{

  /**
   * @var string
   *
   * @Groups({"list", "details"})
   * @Id
   * @Column(type="string", length=255)
   */
  private $agentId;

  ...

I've already clear doctrine cache, but the error persists. Why is this happening.

Thanks!

danielrvt
  • 10,177
  • 20
  • 80
  • 121
  • 2
    Have you looked [here](http://stackoverflow.com/questions/26187097/doctrine-reflectionexception-property-does-not-exist) and tried to clean doctrine cache? – chapay Mar 13 '15 at 06:25
  • 1. avoid using private properties except are actually need to restrict child's access to this prop. 2. have you updated the getter method for the model identificator? – Vera Mar 13 '15 at 07:21
  • Possibly because you have orm files in MyBundle/Resources/config/doctrine so your annotations are not being seen. Can't mix the two within a bundle. – Cerad Mar 13 '15 at 10:37
  • hey,May i know how you fixed this? – user3425344 Aug 09 '15 at 17:06
  • 1
    Didn't fix it, I ended up using the normal autogenerated id as pk – danielrvt Aug 09 '15 at 17:09
  • ohkay! I am getting a similar error but not for the primary key though.It is showing property does not exist for a field which is not in the entity and which need not be in the entity.Let me know if you have any idea about this.http://stackoverflow.com/questions/31906530/reflectionexception-in-jms – user3425344 Aug 09 '15 at 17:11

1 Answers1

7

clearing cache by app/console its not enough, remove cache folder completely, it works for me

Konrad Rozner
  • 81
  • 2
  • 4