persistence@glassfish.java.net

LEFT OUTER JOIN - ON clause equivalent?

From: Gary Jacobson <gtjacobson_at_gmail.com>
Date: Wed, 12 Sep 2007 18:14:54 +0200

Is there an equivalent to the SQL ON clause in JPQL?

Let's say you want a list of car dealers and how many new vehicles they're
selling.

In SQL you can say:

SELECT d.name, count( v.id )
FROM dealer d LEFT OUTER JOIN vehicle v
ON v.dealer_id = d.dealer_id AND v.type = 'New'
GROUP BY d.name

In JPQL, you only have the WHERE clause which limits your results, making
the outer join useless:

SELECT d.name, count( v.id )
FROM dealer d LEFT OUTER JOIN d.vehicleList v
WHERE v.type = 'New'
GROUP BY d.name

(My actual query is a fair amount more complicated, and I've tried messing
around with IS NULL and IS EMPTY to no avail)

Is there any way to do this?

Thanks
Gary