Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve type of column \"id\" of class

I encounter an this error with Doctrine and Symfony2:

Could not resolve type of column "id" of class "ST\UserBundle\Entity\User"

Statistic

class Statistique
{
    // ...

    // @ORM\ManyToOne(targetEntity="ST\UserBundle\Entity\User")
    // @ORM\JoinColumn(name="idPro", referencedColumnName="id")
    private $user;
}

EDIT #1:

User

use FOS\UserBundle\Model\User as BaseUser;

// @ORM\Table(name="tiers_prov3")
class User extends BaseUser
{
    /**
     * @ORM\Column(name="TIE_ID", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="NONE")
     */
    protected $id;

    // ...
}

I can't figure it out.

like image 531
Julien Bourdic Avatar asked Jan 05 '16 16:01

Julien Bourdic


Video Answer


1 Answers

Your column name for $id property in User class is "TIE_ID". So try to use this name instead of id in your Statistic class :

/**
 * @var string
 *
 * @ORM\ManyToOne(targetEntity="ST\UserBundle\Entity\User")
 * @ORM\JoinColumn(name="idPro", referencedColumnName="TIE_ID") <== here
 */
private $user;

In Doctrine annotations, columns names - like in @ORM\Column(name="x"...) and @ORM\JoinColumn(name="y", referencedColumnName="x" ...) - are real database column names.

like image 187
scandel Avatar answered Oct 07 '22 16:10

scandel