title: Add where clause for joined table with JPA Criteria API
body: <p>I have an one to many association between vocab and vocabml, </p>
  
  <p>what need to be done with simple query (join two tables and filter based on description conditions):</p>
  
  <pre><code>select  * from vocab v
  left join vocabml vm on vm.vocabid = v.id and vm.locale in ('uk','en'....)
  where v.description like '%syst%'
  or vm.description like '%syst%'
  </code></pre>
  
  <p>My attempt with criteria API raises exception: <code>Caused by: java.lang.IllegalStateException: Illegal attempt to dereference path source [null.vocabmls] of basic type</code></p>
  
  <p>My code:</p>
  
  <pre><code>CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery&lt;Vocab&gt; criteriaQuery = builder.createQuery(Vocab.class);
  criteriaQuery.distinct(true);
  
  Root&lt;Vocab&gt; root = criteriaQuery.from(Vocab.class);
  root.fetch("vocabmls", JoinType.LEFT);
  
  List&lt;Predicate&gt; predicates = = new ArrayList&lt;&gt;();
  
  
  Predicate predicate = builder.or(builder.like(root.get("description"), "%" + description + "%"),
                        builder.like(root.get("vocabmls").get("description"), "%" + description + "%"));
  predicates.add(predicate)
  
  if(locales != null){
      List&lt;String&gt; ids = locales.stream().map(Locale::getId).collect(Collectors.toList());
      Join&lt;Vocab, Vocabml&gt; vocabmlJoin = root.join("vocabmls", JoinType.LEFT);
      vocabmlJoin.on(builder.and(vocabmlJoin.&lt;Vocabml&gt; get("localeId").in(ids)));
  }
  
  criteriaQuery.where(predicates.toArray(new Predicate[] {})).orderBy(builder.asc(root.get("description")));
  return entityManager.createQuery(criteriaQuery).getResultList();
  </code></pre>