title: How to make a CriteriaBuilder join with a custom "on" condition?
body: <p>I want make a query where I join 2 tables, using the CriteriaBuilder. In MySQL the query I'm trying to make would look like this:</p>
  
  <pre><code>SELECT * FROM order
  LEFT JOIN item
  ON order.id = item.order_id
  AND item.type_id = 1
  </code></pre>
  
  <p>I want to get all orders and if they have an item of type #1, I want to join with this item. However, if no item of type #1 is found, I still want to get the order. I can't figure out how to make this with the CriteriaBuilder. All I know how to make is:</p>
  
  <pre><code>CriteriaBuilder cb = em.getCriteriaBuilder();
  CriteriaQuery&lt;Order&gt; cq = cb.createQuery(Order.class);
  Root&lt;Order&gt; order = cq.from(Order.class);
  Join&lt;Order, Item&gt; item = order.join(Order_.itemList, JoinType.LEFT);
  Join&lt;Item, Type&gt; type = order.join(Item_.type, JoinType.LEFT);
  cq.select(order);
  cq.where(cb.equal(type.get(Type_.id), 1));
  </code></pre>
  
  <p>This query is broke, since it results in something like this in MySQL:</p>
  
  <pre><code>SELECT * FROM order
  LEFT JOIN item
  ON order.id = item.order_id
  WHERE item.type_id = 1
  </code></pre>
  
  <p>The result will only contain orders with items of type #1. Orders without are excluded. How can I use the CriteriaBuilder to create a query like in the first example?</p>