Tuấn Phạm
Tuấn Phạm

Reputation: 688

Hibernate : invalid ORDER BY expression

I have tried to add some Order to my Criteria like this.

crit.addOrder(Order.asc("priority")); // Not the real property though

And test on my System using a MsAccess database with HSQLDialect And i get

Caused by: org.hsqldb.HsqlException: invalid ORDER BY expression

So i tried to show the query, it reads like this :

Hibernate: 
/* criteria query */ select
    distinct this_.i_id as y0_ 
from
    T_FIT_ARTICLE this_ 
where
    (
        this_.b_export_ready=? 
        or this_.d_application_deadline>=?
    ) 
order by
    this_.d_application_deadline asc limit ? 
//FROM HERE THE STACK TRACE

the thing is, i used the @OrderBy annotation on my collection before, which produce the same query, and this works :

order by
    elements2_.i_order_nr asc limit ?

But with the attributes in my Entity, it causes exception.

By the way, if i try to test the same programm with MYSQLSERVER, it works perfectly.

Any idea why or how could i avoid this ?

Many thanks !

Upvotes: 4

Views: 1524

Answers (1)

Tuấn Phạm
Tuấn Phạm

Reputation: 688

For anyone who is still interested : The Problem was i set up an Projection of an Attribute and set Orders of another attribute. This is apparently not supported by the Dialect or the Database.

Upvotes: 2

Related Questions