title: jpa fetch join query
body: <p>This is how my domain looks:</p>
  
  <pre><code>public class Template implements Serializable {
      private static final long serialVersionUID = 1L;    
      @OneToOne(cascade=CascadeType.ALL)
      private FieldConfig fieldConfig;
  }
  
  public class FieldConfig implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @OneToMany(cascade= CascadeType.PERSIST)
      @JoinColumn(name = "fieldConfigId")
      private Set&lt;Field&gt; fieldSet;
  }
  </code></pre>
  
  <p>I want to achieve if I load a template from the db that automatically the fieldConfig is loaded and the fieldSet of that fieldconfig.</p>
  
  <p>my current JPQL:</p>
  
  <pre><code>TypedQuery&lt;Template&gt; query = em.createQuery("SELECT t from Template t LEFT JOIN FETCH t.fieldConfig"
                  + " fconfig LEFT JOIN FETCH fconfig.fieldSet where t.id = :id", Template.class);
  </code></pre>
  
  <p>my exception:</p>
  
  <pre><code>Internal Exception: NoViableAltException(80@[()* loopback of 477:9: (node= join )*])
  Exception Description: Syntax error parsing the query [SELECT t from Template t LEFT JOIN FETCH t.fieldConfig fconfig LEFT JOIN FETCH fconfig.fieldSet where t.id = :id], line 1, column 55: unexpected token [fconfig].
  </code></pre>
  
  <p>Any thoughts on creating such a query?</p>