开发者

HQL specify an order by property order?

开发者 https://www.devze.com 2022-12-30 07:37 出处:网络
How can I order by a specific property order in HQL? For MySQL I can use: SELECT * FROM question q ORDER BY q.status IN (\"DONE\", \"NO_ACTION\"), q.status IN (\"NEW\",\"SAVED\"), q.created DESC

How can I order by a specific property order in HQL?

For MySQL I can use: SELECT * FROM question q ORDER BY q.status IN ("DONE", "NO_ACTION"), q.status IN ("NEW","SAVED"), q.created DESC

but HQL doesn't allow in in order by.

Am I missing something? Is there some other way around this problem?

Tha开发者_运维百科nks


It seems to me that MySQL syntax using ORDER BY xxx IN (XXX,XXX...) is not SQL-ANSI supported function, it's a specific MySQL function.

So you should figure out another way to do what you want, by not using this function.

You can find here all the function supported by HQL.


Not to revive a dead question, but

SELECT * FROM question q ORDER BY q.status IN ("DONE", "NO_ACTION"), q.status HAVING q.status IN ("NEW", "SAVED")

Find "having clause"

0

精彩评论

暂无评论...
验证码 换一张
取 消