title: how to do a JOIN FETCH in jpa criteria
body: <p>I am trying to translate the query below to criteria api.</p>
  
  <pre><code>SELECT er from ereturn er JOIN FETCH product_item pi ON pi.ereturn_id = er.id WHERE pi.status = "RECEIVED"
  </code></pre>
  
  <p>To something like this:</p>
  
  <pre><code>CriteriaBuilder builder = em.getCriteriaBuilder();
  
  CriteriaQuery&lt;Ereturn&gt; criteria = builder.createQuery( Ereturn.class );
  
  Root&lt;Ereturn&gt; er = criteria.from(Ereturn.class);
  Join&lt;Ereturn, ProductItem&gt; productItemJoin = er.join("productItems", JoinType.LEFT);
  Fetch&lt;Ereturn, ProductItem&gt; productItemFetch = er.fetch("productItems", JoinType.LEFT);
  
  List&lt;Predicate&gt; predicates = new ArrayList&lt;&gt;();
  
  predicates.add(builder.equal( productItemJoin.get( "status" ), "RECEIVED"));
  
  criteria.where(
          builder.and(predicates.toArray(new Predicate[predicates.size()]))
  );
  
  List&lt;Ereturn&gt; ers = em.createQuery( criteria )
      .getResultList();
  </code></pre>
  
  <p>The problem is that hibernate generates this query:</p>
  
  <pre><code>select
  ereturn0_.id as ...
  ...
  productite6_.id as ...
  ...
  from
  ereturn ereturn0_ 
  join
  product_item productite1_ 
  on ereturn0_.id = productite1_.ereturn 
  join
  product_item productite6_ 
  on ereturn0_.id = productite6_.ereturn
  where
  productite1_.status='RECEIVED';
  </code></pre>
  
  <p><strong>QUESTION:</strong> how could I tell hibernate to generate this query with only 1 join while fetching fields from both tables (ereturn and productItem)?</p>