Considering the two entities below:
/**
* @ORM\Table(name="cliente")
* @ORM\Entity
*/
class Cliente {
/**
* @ORM\Column(name="id_cliente", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=50)
*/
private $nome;
// getters, setters, etc...
}
/**
* @ORM\Table(name="pedido")
* @ORM\Entity
*/
class Pedido {
/**
* @ORM\Column(name="id_pedido", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Cliente")
* @ORM\JoinColumn(name="id_cliente", referencedColumnName="id_cliente")
*/
private $cliente;
// getters, setters, etc...
}
Is it possible to do the following search?
$criteria = Criteria::create()->where(Criteria::expr()->contains('cliente.nome', 'Felippe'));
$pedidos = $this->entityManager->getRepository('Admin\Models\Pedido')
->matching($criteria);
The following error is being returned:
Unrecognized field: client.name
I developed a utility class package to handle the searches of the jQuery DataTables plugin, and for this I created a GenericDAO.