title: Left Outer Join in Criteria Api
body: <p>I'm trying to get the following query using the Criteria API:</p>
  
  <pre><code>select lang.* from LKUP_LANG lang LEFT OUTER JOIN LANG_SEQUENCES seq ON
  lang.SHORT_NAME=seq.LANG_CODE and (lang.DISPLAY_NAME is not null)
  order by nvl(seq.SEQ_LANG_CODE, 2147483647) asc;
  </code></pre>
  
  <p>I did:</p>
  
  <pre><code>CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery&lt;Lang&gt; criteriaQuery = builder.createQuery(Lang.class);
  Root&lt;Lang&gt; languageRoot = criteriaQuery.from(Lang.class);
  
  List&lt;Predicate&gt; predicates = new ArrayList&lt;&gt;();
  // added some predicates
  criteriaQuery.orderBy(...);
  </code></pre>
  
  <p>Tried adding </p>
  
  <pre><code>Join&lt;Lang, LANG_SEQUENCES&gt; join = languageRoot.join("languageSequences",JoinType.LEFT);
  </code></pre>
  
  <p>The entity looks like</p>
  
  <pre><code>LanguageSequences
  @Id
  @Column(name = "LANG_CODE")
  private String langCode;
  
  @Column(name = "SEQ_LANG_CODE")
  private int seqLangcode;
  
  @OneToOne
  @Fetch(FetchMode.JOIN)
  @JoinColumn(name = "LANG_CODE", referencedColumnName = "SHORT_NAME")
  private Lang lang;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Lang
  @Column(name = "DISPLAY_NAME", unique = true)
  private String displayName;
  
  @Id
  @Column(name = "SHORT_NAME")
  private String shortName;
  
  @OneToOne(cascade = CascadeType.ALL, mappedBy = "lkupLanguage")
  private LanguageSequences languageSequences;
  </code></pre>
  
  <p>Tried using joins in different ways but it looks like I'm missing something. I get the orderBy, the predicates all correct.
  I'm using JPA 2.1 and Oracle.</p>