title: Java: JPQL select statement
body: <p><code>select x from X x where x.a.id = :a_id</code> --> Always 0 objects selected</p>
  
  <p>Why does the above JPQL statement not work, but the one below work?</p>
  
  <p><code>select a from A a where a.id = :a_id</code> --> a_obj<br>
  <code>select x from X x where x.a = :a_obj</code> --> Always correct number of objects selected</p>
  
  <p>Neither query throws an exception during execution, but a different number of results are obtained.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>I tried the following queries by using joins:<br>
  <code>select x from X x, x.a a where x.a.id = :a_id</code> --> TopLink exception for unexpected token</p>
  
  <p>and this:
  <code>select x from X x JOIN x.a a where a.id = :a_id</code> --> Always correct number of objects selected</p>
  
  <p>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.</p>
  
  <p><code>select x from X x where x.a.id = :a_id</code> --> Always 0 objects selected<br>
  <code>select x from X x, x.a a where x.a.id = :a_id</code> --> TopLink exception for unexpected token</p>
  
  <p>Has anyone else encountered similar behaviour?</p>