简体   繁体   中英

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 !

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM