persistence@glassfish.java.net

Re: Unexpected token: ORDER

From: Dies <dies_at_jp.fujitsu.com>
Date: Wed, 9 Apr 2008 02:16:22 -0700 (PDT)

JPQL does not allow the use of ORDER BY in a subquery:

subquery_from_clause ::=
FROM subselect_identification_variable_declaration
{, subselect_identification_variable_declaration}*

Why do you need it?



MariusW wrote:
> Internal Exception: line 1:273: unexpected token: ORDER
>
> In a more readable format, the EJB QL looks like this:
> UPDATE MobileMessage x
> SET x.statusmsg = 'PROCESSING',x.transporttime = :transporttime
> WHERE x.id IN (
> SELECT y.id FROM MobileMessage y
> WHERE y.gateway = :gateway
> AND y.statusmsg IN ( 'PENDING','RETRY','SCHEDULED')
> AND ((y.timetosend IS NULL) OR (y.timetosend < :cutoff ))
> ORDER BY y.priority
> )
>
> If I translate it to standard SQL and execute it, it works fine:
> UPDATE bb_core.bb_message
> SET statusmsg = 'PROCESSING'
> WHERE id IN (
> SELECT id FROM bb_core.bb_message
> WHERE gateway = 1
> AND statusmsg IN ( 'PENDING','RETRY','SCHEDULED')
> AND ((timetosend IS NULL) OR (timetosend < now() ))
> ORDER BY priority
> )
>
> Any tips would be greatly appreciated!
>
> // Marius
>

-- 
View this message in context: http://www.nabble.com/Unexpected-token%3A-ORDER-tp16582059p16582811.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.