I have this entity named Pointscomptage.php
:
class Pointscomptage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="invariant", type="string", length=150, nullable=false)
*/
private $invariant;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=150, nullable=false)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="consoProduction", type="string", length=150, nullable=false)
*/
private $consoProduction;
/**
* @var Typesenergie
*
* @ORM\ManyToOne(targetEntity="Typesenergie", inversedBy="pointscomptage")
* @ORM\JoinColumn(name="typesenergie_id", referencedColumnName="id")
*/
private $typesenergie;
/** ... getters and setters */
I need to understand how to create a ManyToMany recursive or reflexive relation on this entity.
That is to say, a Pointscomptage could have no (0) or many (n) Pointscomptage.
How to make this relation on this same entity?
EDIT
Thanks to Jovan Perovic answer and suggestion this the solution I found, we need to respect doctrine annotation:
/**
* @ORM\ManyToMany(targetEntity="Pointscomptage")
* @ORM\JoinTable(name="pointscomptage_link_table",
* joinColumns={
* @ORM\JoinColumn(name="pointscomptage_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="id_pointscomptage2", referencedColumnName="id")
* }
* )
**/
private $pointscomptages;
Thank you a lot.