Sigh... I feel like we should've used common sense and built our own QL based 
on EJBQL/JPQL instead of blindly following the JPA spec. Which among other 
things says "The Java Persistence query language includes [...] built-in 
functions, which may be used in the WHERE or HAVING clause of a query." So no 
ORDER BY in this list :-/

>  I searched the code but those 10k lines are quite a challenge.

You betcha. 

We should prolly add it. Hope most DB's support it.

Andrus

On Jul 11, 2011, at 5:36 PM, Marek Šabo wrote:
> Hi all,
> 
> I was trying to push a query through parser today and it didn't make it.
> 
> "SELECT stt FROM SubTaskType stt ORDER BY ABS(stt.code) ASC"
> 
> Exception is below, my question being whether it is correct behaviour or a 
> bug. I know mysql allows such syntax and oracle too (it allows numeric 
> sorting of strings). I searched the code but those 10k lines are quite a 
> challenge.
> 
> Regards,
> 
> Marek
> 
> Caused by: org.apache.cayenne.ejbql.parser.ParseException: Encountered " 
> "ABS" "ABS "" at line 1, column 42.
> Was expecting one of:
> <IDENTIFIER> ...
>    "db:" ...
> 
>        at 
> org.apache.cayenne.ejbql.parser.EJBQL.generateParseException(EJBQL.java:9418)
>        at 
> org.apache.cayenne.ejbql.parser.EJBQL.jj_consume_token(EJBQL.java:9297)
>        at org.apache.cayenne.ejbql.parser.EJBQL.path(EJBQL.java:623)
>        at org.apache.cayenne.ejbql.parser.EJBQL.orderby_item(EJBQL.java:5138)
>        at 
> org.apache.cayenne.ejbql.parser.EJBQL.orderby_clause(EJBQL.java:5097)
>        at 
> org.apache.cayenne.ejbql.parser.EJBQL.select_statement(EJBQL.java:93)
>        at org.apache.cayenne.ejbql.parser.EJBQL.parseQuery(EJBQL.java:41)
>        at 
> org.apache.cayenne.ejbql.parser.EJBQL$EJBQLDefaultParser.compile(EJBQL.java:30)
> 

Reply via email to