title: How to write JPQL SELECT with embedded id?
body: <p>I'm using Toplink essentials (JPA) + GlassFish v3 + NetBean 6.9</p>
  
  <p>I have one table with composite primary key:</p>
  
  <pre><code>table (machine)
  ----------------
  |PK machineId  |
  |PK workId     |
  |              |
  |______________|
  </code></pre>
  
  <p>I created 2 entity classes one for entity itself and second is PK class.</p>
  
  <pre><code>public class Machine {
     @EmbeddedId
     protected MachinePK machinePK;
  
     //getter setters of fields..
  }
  
  public class MachinePK {
      @Column(name = "machineId")
      private String machineId;
  
      @Column(name = "workId")
      private String workId;
  
  }
  </code></pre>
  
  <p>Now.. <strong>how do I write SELECT clause with JPQL with WHERE???</strong></p>
  
  <p>This fails.</p>
  
  <pre><code>SELECT m FROM Machine m WHERE m.machineId = 10
  </code></pre>
  
  <p><a href="http://www.mail-archive.com/users@openjpa.apache.org/msg03073.html" rel="noreferrer">http://www.mail-archive.com/users@openjpa.apache.org/msg03073.html</a></p>
  
  <p>According to the web page, add "val"? No it fails too.</p>
  
  <pre><code>   SELECT m FROM Machine m WHERE m.machineId.val = 10
  </code></pre>
  
  <p>In both case, the error is:</p>
  
  <pre><code>    Exception Description: Error compiling the query 
  [SELECT m FROM Machine m WHERE m.machineId.val = 10], 
  line 1, column 30: unknown state or association field 
  [MachineId] of class [entity.Machine].
  </code></pre>