title: JPQL table join query
body: <p>How do I get JPA &amp; JPQL to pass a complete join query to the RDBMS? For example,</p>
  
  <pre><code>SELECT e
  FROM Employee e
  WHERE a.runkey = e.runkey
    AND e.middle = 'M'
    AND a.state = 'MA'
  </code></pre>
  
  <p>With the following Employee class</p>
  
  <pre><code>@Entity
  public class Employee implements Serializable {
  
    blah ... blah
  
    @OneToOne
    @JoinColumn(
      name = "runkey",
      referencedColumnName = "runkey",
      insertable=false, updatable=false)
    private Address address;
  }
  </code></pre>
  
  <p>and the JPQL,</p>
  
  <pre><code>SELECT e
  FROM Employee e
  INNER JOIN FETCH e.address AS a
  WHERE a.state = :state
   AND e.middle = :middle
  </code></pre>
  
  <p>I am able to get Hibernate JPA to pull the data as expected.</p>
  
  <p>However, eclipselink croaks that it cannot traverse associated field "address".</p>
  
  <p>If so, how then should I design the Employee entity and how should I phrase the JPQL in order to get eclipselink to execute a table join with WHERE filters on both tables?</p>
  
  <p>(Rant: Otherwise Eclipselink JPA is no better than JDO!!!)</p>
  
  <p>~</p>
  
  <p><strong>Further edit</strong>: Does this post mean anything to my case  ....<br/>
  <a href="https://forums.oracle.com/forums/thread.jspa?threadID=1568659" rel="nofollow">https://forums.oracle.com/forums/thread.jspa?threadID=1568659</a></p>