orderBy(...) in JPASubQuery - goes against JPQL specs

62 views
Skip to first unread message

Michael Tontchev

unread,
May 4, 2015, 9:17:06 PM5/4/15
to quer...@googlegroups.com
I have been banging my head against a query where I am using an orderBy() on a JPASubQuery and getting "ORA-00907: missing right parenthesis":

JPASubQuery queryDSLSubQuery = new JPASubQuery();
queryDSLSubQuery.from(intel).where(intel.city.name.eq("Rome"));

JPAQuery queryDSLOuterQuery = new JPAQuery(em);
queryDSLOuterQuery.from(intel).where(intel.in(queryDSLSubQuery.list(intel)));

This produces select intel from Intel intel where intel in (select intel from Intel intel where intel.city.name = ?1 order by intel.city.name asc).

After posting to Stack Overflow, I've learned that JPQL does not allow "ORDER BY" clauses in subqueries. Why do we have that functionality in QueryDSL, then? If the answer is "because we use a workaround", then why is QueryDSL generating JPQL (like what is seen above) that explicitly puts the order by clause in there?

Thanks!

timowest

unread,
May 5, 2015, 3:57:06 PM5/5/15
to quer...@googlegroups.com
Hi Michael.

Could you open a ticket for disallowing order usage in JPASubQuery?

Also what do you mean by workaround?

Timo

Michael Tontchev

unread,
May 5, 2015, 4:51:33 PM5/5/15
to quer...@googlegroups.com
Submitted: https://github.com/querydsl/querydsl/issues/1346

Hopefully I did it right - I've never done it before :)

As to the workaround thing - I didn't mean anything specific by it, I was just wondering whether there was a reason why orderBy was allowed - I thought you might be using a workaround that failed or something like that. Again, I didn't mean anything beyond that.
Reply all
Reply to author
Forward
0 new messages