EDIT
Let’s take the following model :

The following entities are generated with the command doctrine:mapping:import :
class Toto
{
/**
* @var integer $idtoto
*
* @ORM\Column(name="idtoto", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idtoto;
/**
* Get idtoto
*
* @return integer
*/
public function getIdtoto()
{
return $this->idtoto;
}
}
class Tata
{
/**
* @var integer $idtata
*
* @ORM\Column(name="idtata", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idtata;
/**
* @var Toto
*
* @ORM\ManyToOne(targetEntity="Toto")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="idtoto", referencedColumnName="idtoto")
* })
*/
private $idtoto;
/**
* Get idtata
*
* @return integer
*/
public function getIdtata()
{
return $this->idtata;
}
/**
* Set idtoto
*
* @param Creatis\SaisieBundle\Entity\Toto $idtoto
*/
public function setIdtoto(\Creatis\SaisieBundle\Entity\Toto $idtoto)
{
$this->idtoto = $idtoto;
}
/**
* Get idtoto
*
* @return Creatis\SaisieBundle\Entity\Toto
*/
public function getIdtoto()
{
return $this->idtoto;
}
}
Why is the relation OneToMany in class Toto NOT generated (had to type it by hand) :
/**
* @ORM\OneToMany(targetEntity="Tata", mappedBy="idToto")
*/
private $tatas;
Is there an option to put in the command line ?
Within leftJoin, you just have to use the name of your relation attribute as defined in the Tata class. The second parameter only defines the key you can use in the statement. If your relations are correct, doctrine does the join automatically:
If you don’t want to join with the foreign key but some other fields, you have to add a thrid parameter to leftJoin which does the matching, like
toto.field1 = tata.field2.