Oneill
Oneill

Reputation: 339

Relationship ManyToMany, the extra field ignored

I have a problem certainly very stupid .

I have 3 entities : activity , category and categorieActivite which the following codes :

/**
 * Class Activite
 * @ORM\Entity
 * @ORM\Table(name="activite")
 */
 class Activite{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
* @ORM\Column(type="string",length=255)
*/
protected $nom;

/**
 * @ORM\OneToMany(targetEntity="CategorieActivite",mappedBy="activite")
 */
protected $categorieList;

 }


 class Categorie{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
 * @ORM\Column(type="string",length=255)
 */
protected $nom;

/**
 * @ORM\OneToMany(targetEntity="CategorieActivite",mappedBy="categorie")
 */
protected $activiteList;
}


class CategorieActivite{


/**
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Categorie",inversedBy="activiteList")
 * @ORM\JoinColumn(name="categorie_id", referencedColumnName="id", nullable=false)
 */
protected $categorie;

/**
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Activite",inversedBy="categorieList")
 * @ORM\JoinColumn(name="activite_id", referencedColumnName="id", nullable=false)
*/
protected $activite;

/**
 * ORM\Column(type="string",length=50)
 * @Assert\Choice(choices = {"Intense", "Douce", "Moyenne"}, message = "Veuillez choisir une valeur")
 * @Assert\NotNull()
 */
protected $intensite;

}

So far all working properly. But the problem is that the intensity of CategorieActivite entity does not appear in the database , there are only foreign keys that appear. Do you have an idea of the problem?

Thank you in advance for your help.

Thibault.

Upvotes: 1

Views: 36

Answers (1)

Richard
Richard

Reputation: 4119

On your $intensite property

* ORM\Column(type="string",length=50)

Should be:

* @ORM\Column(type="string",length=50)

Pretty sure that'll fix it for you. You'll need to run a doctrine:migrations:diff once you fix the annotation.

Upvotes: 2

Related Questions