title: HQL 'with' clause in JPQL
body: <p>From Hibernate 3.6 documentation:</p>
  
  <blockquote>
    <p>You may supply extra join conditions using the HQL with keyword. </p>
  </blockquote>
  
  <pre><code>from Cat as cat
  left join cat.kittens as kitten
      with kitten.bodyWeight &gt; 10.0
  </code></pre>
  
  <p>This <code>with</code> clause allows to add a restriction on the JOIN condition (ON clause). Is there any such thing in JPQL?</p>
  
  <p>When I run the following JPQL:</p>
  
  <pre><code>select c from ContainerDef c left join fetch c.displayState ds where c.id = 1 and ds.user.id = 2
  </code></pre>
  
  <p>The following SQL is generated:</p>
  
  <pre><code>select
          ...
      from
          CONTAINER_DEF containerd0_ 
      left outer join
          USER_CONTAINERDEF displaysta1_ 
              on containerd0_.CONTAINERDEF_ID=displaysta1_.CONTAINERDEF_ID 
      where
          containerd0_.CONTAINERDEF_ID=? 
          and displaysta1_.AUTHUSER_ID=?
  </code></pre>
  
  <p>What should really get generated is:</p>
  
  <pre><code>select
          ...
      from
          CONTAINER_DEF containerd0_ 
      left outer join
          USER_CONTAINERDEF displaysta1_ 
              on containerd0_.CONTAINERDEF_ID=displaysta1_.CONTAINERDEF_ID 
              and displaysta1_.AUTHUSER_ID=?
      where
          containerd0_.CONTAINERDEF_ID=? 
  </code></pre>
  
  <p>I am sure I'm missing the right JPQL clause for HQL's <code>with</code>.</p>