2
votes

I have UserBundle who extends FOSUserBundle, and entity User who extends FOS's User class. On my localhost work fine, but on hosting i've got error:

Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'No identifier/primary key specified for Entity "WisJa\CoreBundle\Entity\User" sub class of "FOS\UserBundle\Model\User". Every Entity must have an identifier/primary key.' in...

My User entity all code:

<?php
namespace WisJa\CoreBundle\Entity;

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

/**
 * @ORM\Table(name="fos_user")
 * @ORM\Entity
 */
class User extends BaseUser
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

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

public function __construct()
{
    parent::__construct();
    // your own logic
}

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

/**
 * Set facebook
 *
 * @param string $facebook
 * @return User
 */
public function setFacebook($facebook)
{
    $this->facebook = $facebook;

    return $this;
}

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

I have no idea why it works on localhost but don't works in web...

1
Try to clear cache dirVictor Bocharsky
It's weird... I've clear cache dir before upload files and then i've got error, now i clean cache again and now it works :o So, thanks for help, now all works :)Jacek
I have this problem tooVictor Bocharsky
Yes, always clear the cache after putting new files there: there's a (small) chance a request between clearing & uploading will cache the old code instead of the new one.Wrikken

1 Answers

2
votes

You need to completely clear the cache dir at your hosting. Sometimes it's better to do rm -rf var/cache/* instead of using the Symfony console, but sometimes this could cause some permission issues. It depends on your server configuration.