title: JPA Criteria query Path.get left join is it possible
body: <p>I have a question regarding JPA criteria.</p>
  
  <p>Here is my JPA criteria query:</p>
  
  <pre><code> CriteriaBuilder criteriaBuilder = getEm().getCriteriaBuilder();
   CriteriaQuery&lt;InventoryItemSumReport&gt; query = criteriaBuilder.createQuery(InventoryItemSumReport.class);
   Root&lt;InventoryItemDetail&gt; from = query.from(InventoryItemDetail.class);    
  
   Join&lt;InventoryItemDetail, InventoryItem&gt; joinItem = from.join(InventoryItemDetail_.inventoryItem); 
  
   Predicate where = criteriaBuilder.lessThanOrEqualTo(from.get(InventoryItemDetail_.effectiveDate), date);
  
   query.multiselect(joinItem.get(InventoryItem_.product),joinItem.get(InventoryItem_.facility),joinItem.get(InventoryItem_.customer));
   query.groupBy(joinItem.get(InventoryItem_.product),joinItem.get(InventoryItem_.facility),joinItem.get(InventoryItem_.customer));
   query.where(where); 
  
   TypedQuery&lt;InventoryItemSumReport&gt; createQuery = getEm().createQuery(query);       
   List&lt;InventoryItemSumReport&gt; resultList = createQuery.getResultList();
  </code></pre>
  
  <p>Here is the resulting query produced by the JPA provider:</p>
  
  <pre><code>    select
          inventoryi1_.PRODUCT_ID as col_0_0_,
          inventoryi1_.FACILITY_ID as col_1_0_,
          inventoryi1_.CUSTOMER_ID as col_2_0_ 
      from
          INVENTORY_ITEM_DETAIL inventoryi0_ 
      inner join
          INVENTORY_ITEM inventoryi1_ 
              on inventoryi0_.INVENTORY_ITEM_ID=inventoryi1_.ID 
      inner join
          PRODUCT product2_ 
              on inventoryi1_.PRODUCT_ID=product2_.ID 
      inner join
          FACILITY facility3_ 
              on inventoryi1_.FACILITY_ID=facility3_.ID 
      inner join
          CUSTOMER customer4_ 
              on inventoryi1_.CUSTOMER_ID=customer4_.ID 
      where
          inventoryi0_.EFFECTIVE_DATE&lt;= ? 
      group by
          inventoryi1_.PRODUCT_ID ,
          inventoryi1_.FACILITY_ID ,
          inventoryi1_.CUSTOMER_ID
  </code></pre>
  
  <p>But I would like the following query:</p>
  
  <pre><code>    select
          inventoryi1_.PRODUCT_ID as col_0_0_,
          inventoryi1_.FACILITY_ID as col_1_0_,
          inventoryi1_.CUSTOMER_ID as col_2_0_ 
      from
          INVENTORY_ITEM_DETAIL inventoryi0_ 
      inner join
          INVENTORY_ITEM inventoryi1_ 
              on inventoryi0_.INVENTORY_ITEM_ID=inventoryi1_.ID 
      inner join
          PRODUCT product2_ 
              on inventoryi1_.PRODUCT_ID=product2_.ID 
      inner join
          FACILITY facility3_ 
              on inventoryi1_.FACILITY_ID=facility3_.ID 
      left join
          CUSTOMER customer4_ 
              on inventoryi1_.CUSTOMER_ID=customer4_.ID 
      where
          inventoryi0_.EFFECTIVE_DATE&lt;= ?
      group by
          inventoryi1_.PRODUCT_ID ,
          inventoryi1_.FACILITY_ID ,
          inventoryi1_.CUSTOMER_ID
  </code></pre>
  
  <p>with a <strong>left join CUSTOMER</strong> to get also results where <code>Customers</code> are null.<br>
  <code>Customer</code>, <code>Product</code>, <code>Facility</code> are all entites, while <code>InventoryItemSumReport</code> is a Value  object or DTO.</p>
  
  <pre><code>public class InventoryItemSumReport implements Serializable {
  
     private static final long serialVersionUID = 1L;
  
     private Product product;
     private Facility facility;
     private Customer customer;
  
     public InventoryItemSumReport(Product product, Facility facility, Customer customer) {
         super();
         this.product = product;
         this.facility = facility;
         this.customer = customer;
     }
  }
  </code></pre>