title: Criteria API is not generating left outer join
body: <p>I have 3 entities, infact many more joined together for brevity i'm skipping those and i'm using open jpa 2.2.2 and oracle 11g. Any thoughts what's going wrong here?  </p>
  
  <pre><code>Entity SystemRules{
  @OneToMany(mappedBy = "systemRule", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      private List&lt;ServiceActionMap&gt; serviceActionMap;
  }
  
  Entity ServiceActionMap{
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "SYSTEM_RULE_ID")
      private SystemRules systemRule;
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "RFS_TYPE_ID", nullable = true)
      private RfsTypeMap rfsType;
  }
  
  Entity RfsTypeMap{
      @Id
      @Column(name="RFS_TYPE_ID" ,nullable=false)
      private BigDecimal rfsTypeId;
  
      @Column(name="RFS_NAME")
      private String rfsName;
  }
  </code></pre>
  
  <p>Now, I am trying to order the result by RfsTypeMap.rfsName, i'm creating query using criteria builder in following manner</p>
  
  <pre><code>CriteriaQuery&lt;SystemRules&gt; query = cb.createQuery(SystemRules.class);
  Root&lt;SystemRules&gt; root= query.from(SystemRules.class);
  root.fetch(SystemRules_.serviceActionMap).fetch(ServiceActionMap_.rfsType, JoinType.LEFT);
  </code></pre>
  
  <p>My order by clause is like this</p>
  
  <pre><code>cb.desc(cb.upper(systemRules.get("serviceActionMap").get("rfsType").get("rfsName").as(String.class)));
  </code></pre>
  
  <p>Generate JPQL looks like, where i expect a left outer join clause between ServiceActionMap and RfsTypeMap but it's missing. Same gets translated in SQL and i miss those records which are having  ServiceActionMap.rfsType as null value.</p>
  
  <pre><code>SELECT  DISTINCT s FROM SystemRules s INNER JOIN FETCH s.serviceActionMap  INNER JOIN FETCH s.serviceActionMap  INNER JOIN FETCH s.ruleProperty  INNER JOIN FETCH s.ruleProperty where ... ORDER BY UPPER(s.serviceActionMap.rfsType.rfsName)
  </code></pre>
  
  <p>I tried going over several answers here but no success, tried explicitly putting a where clause for ServiceActionMap.rfsType is null as suggested on few answers but it's getting ignored, since join happens before where evaluation. Somewhere this question <a href="https://stackoverflow.com/questions/19845889/openjpa-outer-join-on-optional-many-to-one-when-have-order-by-clause">openJPA outer join on optional many-to-one when have order by clause</a> matches my scenario but not able to generate suggested JPQL through criteria API. </p>
  
  <p>I found one related bug on apache jira <a href="https://issues.apache.org/jira/browse/OPENJPA-2318" rel="nofollow noreferrer">https://issues.apache.org/jira/browse/OPENJPA-2318</a>. But, not sure that's the case. </p>