I have two entities MarcaAuto and ModeloAuto with the following definition:
MarcaAuto
<?php
namespace FrontEndBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MarcaAuto
*
* @ORM\Table(name="marcas_auto")
* @ORM\Entity(repositoryClass="FrontEndBundle\Repository\MarcaAutoRepository")
*/
class MarcaAuto
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\OneToMany(targetEntity="ModeloAuto", mappedBy="idMarca")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $marca;
ModeloAuto
<?php
namespace FrontEndBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ModeloAuto
*
* @ORM\Table(name="modelos_auto")
* @ORM\Entity(repositoryClass="FrontEndBundle\Repository\ModeloAutoRepository")
*/
class ModeloAuto {
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var int
* @ORM\Column(name="id_marca", type="integer")
* @ORM\ManyToOne(targetEntity="MarcaAuto", inversedBy="id")
* @ORM\JoinColumn(name="id_marca", referencedColumnName="id")
*/
private $idMarca;
By making a statement about the entity in my controller in this way:
AcmeController
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
'SELECT a
FROM FrontEndBundle:MarcaAuto a
LEFT JOIN a.id
ORDER BY a.marca ASC'
);
$marcasVehiculos = $query->getResult();
I get the following error:
[Semantical Error] line 0, col 68 near 'ORDER BY a.brand': Error: Class FrontEndBundle \ Entity \ MarcaAuto has no association named id 500 Internal Server Error - QueryException 1 linked Exception: QueryException »
I have reviewed the documentation again and again and I can not find the error.