I am trying to filter a Doctrine query made with QueryBuilder on a child property when the object have this property.
Basically, I have an abstract class Accommodation with House and Tent as child on a Class table inheritance, as described in the documentation.
House class has a owner property and Tent does not.
This is how I make my queryBuilder.
$qb = $this->createQueryBuilder('a')
->select('a')
->andWhere('(a NOT INSTANCE OF "House") OR (a INSTANCE OF "House" AND a.owner = :owner)')
->setParameter("owner", $user);
Doing that I get an error saying that owner does not exist for Accommodation :
[Semantical Error] line 0, col 299 near 'owner =:owner)': Error: Class AppBundle\Entity\Accommodation has no field or association named owner
Is there any way to ask Doctrine to join the owner column?
PS: This is part of a Symfony3 project but I don't think it matter for the question.