Reputation: 3444
I have some rather simple Entities, on of the is A, A has column parent
annotated with
@ORM\JoinColumn(name="parentid", referencedColumnName="id", nullable=true)
@ORM\ManyToOne(targetEntity="A", inversedBy="children", cascade={"persist"})
Which is basically a reference to another A entity.
When I try to query this Entity A.parent in a query like this
$qb->select("A.parent")
// or
$qb->select("A.parentid")
// or
$qb->select("A.Parent")
$qb->leftJoin("A.parent", "parent")
I end up getting this error:
Entity .... has no field or association named parent/parentid
Upvotes: 0
Views: 486
Reputation: 408
If the definition is something like this
/**
* @ORM\JoinColumn(name="parentid", referencedColumnName="id", nullable=true)
* @ORM\ManyToOne(targetEntity="A", inversedBy="children", cascade={"persist"})
*/
private $parentField;
The query builder should be like this
$qb
->select('a, p')
->from('AppBlogBundle:A', 'a')
->leftJoin('a.parentField','p');
Upvotes: 1