11.4.5. About the WITH Clause
HQL defines a
WITHclause to qualify the join conditions. This is specific to HQL; JPQL does not define this feature.
Example 11.4. with-clause Join Example
select distinct c from Customer c left join c.orders o with o.value > 5000.00
The important distinction is that in the generated SQL the conditions of the
with clauseare made part of the
on clausein the generated SQL as opposed to the other queries in this section where the HQL/JPQL conditions are made part of the
where clausein the generated SQL. The distinction in this specific example is probably not that significant. The
with clauseis sometimes necessary in more complicated queries.
Explicit joins may reference association or component/embedded attributes. In the case of component/embedded attributes, the join is simply logical and does not correlate to a physical (SQL) join.