title: JPA: PersistenceException "unknown state or association field"
body: <p>I am trying to understand how to do (simple) joins in JPQL.  I have two tables/entities: Parent and Child.</p>
  
  <pre><code>@Entity
  @Table(name = "Parent")
  @NamedQueries({
      @NamedQuery(name = "Parent.findByStatus", query = "SELECT p FROM Parent p WHERE p.status = :status")})
  public class Parent
  {
      private String parentId;
      private Set&lt;Child&gt; children;
      private String status;
  
      public Parent()
      {
          // empty constructor
      }
  
      @Id
      @Column(name = "PARENT_ID")
      public String getParentId()
      {
          return parentId;
      }
  
      public void setParentId(String parentId)
      {
          this.parentId= parentId;
      }
  
      // bi-directional many-to-one association to Child
      @OneToMany(mappedBy = "parent")
      public Set&lt;Child&gt; getChildren()
      {
          return children;
      }
  
      public void setChildre(Set&lt;Child&gt; children)
      {
          this.children= children;
      }
      @Column(name = "STATUS")
      public String getStatus()
      {
          return status;
      }
  
      public void setStatus(String status)
      {
          this.status = status;
      }
  }
  
  @Entity
  @NamedQueries({
          @NamedQuery(name = "Child.findByStatus", query = "SELECT c FROM Child c WHERE c.status = :status"),
          @NamedQuery(name = "Child.findByParentId", query = "SELECT c FROM Child c JOIN c.parent p WHERE p.parentId = :parentId"),
          @NamedQuery(name = "Child.findByParentIdAndStatus", query = "SELECT c FROM Child c JOIN c.parent p WHERE p.parentId = :parentId AND c.status = :status") })
  public class Child
  {
      private childId id;
      private String status;
      private Parent parent;
  
      public Child()
      {
          // empty constructor
      }
  
      @Id
      @Column(name = "CHILD_ID")
      public String getChildId()
      {
          return childId;
      }
  
      public void setChildId(String childId)
      {
          this.childId= childId;
      }
  
      // bi-directional many-to-one association to Parent 
      @ManyToOne
      @JoinColumn(name = "PARENT_ID")
      public Parent getParent ()
      {
          return parent;
      }
  
      public void setParent(Parent parent)
      {
          this.parent= parent;
      }
  
      @Column(name = "STATUS")
      public String getStatus()
      {
          return status;
      }
  
      public void setStatus(String status)
      {
          this.status = status;
      }
  }
  </code></pre>
  
  <p>But this causes the following exception:</p>
  
  <pre><code>Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-8030] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.JPQLException
  Exception Description: Error compiling the query [Child.findByParentId: SELECT c FROM Child c JOIN c.parent p WHERE p.parentId = :parentId], line 1, column 47: unknown state or association field [parentId] of class [my.model.Parent].
  </code></pre>
  
  <p>It's my understanding that JPQL traverses the object model on JOINs.  So, in the query:</p>
  
  <pre><code>SELECT c FROM Child c JOIN c.parent p WHERE p.parentId = :parentId
  </code></pre>
  
  <p><code>p</code> is the fetched Parent object associated with the Child objects.  If this is correct, then why I am getting the error?  The Parent object has a parentId field and so should be okay, yes?</p>