Your second query works and is more elegant, but I'll need to use the first, because "o.countryCode LIKE :countryCode" is just a sample of a filter expression that involves an arbitrary number of terms connected by ANDs. Thanks much!

I guess you have to think of Java-type expressions in a SQL-style statement.


On Nov 18, 2008, at 12:22 PM, Landers, Richard wrote:

 I think you just need to compare
SalesOrder with SalesOrder (not SalesOrder with SalesOrder.id).  That
is, the expression "lic.salesOrder=o.id" would have to read
"lic.salesOrder=o" because in EJB QL the expression "lic.salesOrder"
refers to an object, not a column as in SQL.

Also, you could let EJB QL do the join implicitly...

        SELECT  lic.productId, COUNT(lic)
        FROM  License lic
        WHERE  lic.salesOrder.countryCode LIKE :countryCode
        GROUP BY  lic.productId

-- Rich Landers

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to