Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony / Doctrine "refers to the owning side field which does not exist" - but property is present in class

SeUserProgress and SeUser. The SeUserProgress table holds multiple entries per user. This is expressed via the two following mappings.

class: SeUserProgress

/**
* @ORM\ManyToOne(targetEntity="SeUser", inversedBy="progress")
* @ORM\Column(name="user_id", type="integer", nullable=true)
*/ 
private $user;

class: SeUser

/**
* @ORM\OneToMany(targetEntity="SeUserProgress", mappedBy="user")
*/ 
private $progress;

However I keep getting an error message saying

The association PROJECT\ThisBundle\Entity\SeUser#progress refers to the owning side  field PROJECT\ThisBundle\Entity\SeUserProgress#user which is not defined as association.

The association PROJECT\ThisBundle\Entity\SeUser#progress refers to the owning side  field PROJECT\ThisBundle\Entity\SeUserProgress#user which does not exist.

I can even call the progress property via the code below( though it returns all progress for all users ).

$user->getProgress()

Any suggestions as to why Doctrine is not recognising the mapped property would be appreciated.

like image 430
nmcilree Avatar asked Nov 06 '13 14:11

nmcilree


1 Answers

Change your code from @ORM\Column to @ORM\JoinColumn:

/**
 * @ORM\ManyToOne(targetEntity="SeUser", inversedBy="progress")
 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
 */ 
private $user;
like image 106
Benny Avatar answered Oct 05 '22 12:10

Benny