Some months ago I had the same problem and could solve it by turning the 
query around: instead of directly querying cars with a brand,  with a 
specific enginepart, I queried for the specific engineparts that are part 
of a car with a brand (and then only returning those cars).  So instead of 
walking  my objectgraph from Car to EnginePart I did it the other way 
around... and it worked.

Your query would then become something like :
SELECT c FROM EnginePart e JOIN e.car c 
WHERE LOWER (e.engineNumber) LIKE :engineNumber AND LOWER (c.brand) LIKE 
:brand

Curious whether it also works for you... 


On Saturday, 15 March 2014 03:51:29 UTC+1, Hamo wrote:
>
> Hi,
>
> I have a fairly straight forward inheritance hierarchy that I am try to 
> query. The essentials are as follows:
>
> A Car has OneToMany CarPart.
> CarPart canBe an EnginePart or a BobyPart.
> A Car has a *brand*.
> An EnginePart has an *engineNumber*.
> A BodyPart has a *panelNumber*.
>
> 'canBe' is intended to express inverse of an isA relationship. i.e. 
> EnginePart and BodyPart inherit from CarPart
>
> I am trying to find all Cars with their *brand *LIKE a *:query *OR if 
> they have an EnginePart with an *engineNumber *LIKE a *:query*.
>
> Through the query builder API, I have created the following DQL statement:
> SELECT c FROM Car c LEFT JOIN e.carParts p WITH TYPE(p) = EnginePart WHERE 
> LOWER(c.brand) LIKE :query OR LOWER(p.engineNumber) LIKE :query
>
> When I try to execute this query, I get the following error:
>
> [Semantical Error] line 0, col 113 near 'engineNumber) LIKE ': Error: 
> Class CarPart has no field or association named engineNumber
>
> This seems like a bug in the semantics validator not recognising the type 
> guard.
>
> Please any comments are welcomed
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to