select x from X x where x.a.id = :a_id
--> Always 0 objects selected
Why does the above JPQL statement not work, but the one below work?
select a from A a where a.id = :a_id
--> a_obj
select x from X x where x.a = :a_obj
--> Always correct number of objects selected
Neither query throws an exception during execution, but a different number of results are obtained.
Thanks
Update
I tried the following queries by using joins:
select x from X x, x.a a where x.a.id = :a_id
--> TopLink exception for unexpected token
and this:
select x from X x JOIN x.a a where a.id = :a_id
--> Always correct number of objects selected
With the latter query, I have solved the initial problem at hand. However, now I have got two queries which should work, but for some reason don't.
select x from X x where x.a.id = :a_id
--> Always 0 objects selected
select x from X x, x.a a where x.a.id = :a_id
--> TopLink exception for unexpected token
Has anyone else encountered similar behaviour?