Hibernate 命名查询 Order By 参数 [英] Hibernate Named Query Order By parameter
本文介绍了Hibernate 命名查询 Order By 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能指出我们如何将 order by 子句作为命名参数传递给 HQL?
Can anyone point me to how we can pass an order by clause as a named parameter to HQL?
工作示例:
select tb from TransportBooking as tb
and TIMESTAMP(tb.bookingDate, tb.bookingTime) >= current_timestamp() order by tb.bookingDate
不起作用的例子:
select tb from TransportBooking as tb
and TIMESTAMP(tb.bookingDate, tb.bookingTime) >= current_timestamp() order by :order
推荐答案
不支持,输入参数只允许在WHERE
和HAVING
子句中,不能使用参数对于 ORDER BY
子句.或者,如果我改写,您不能对列使用参数,只能使用值.所以,要么:
Not supported, input parameters are only allowed in the WHERE
and HAVING
clauses and you cannot use parameters for the ORDER BY
clause. Or if I rephrase, you can't use parameters for columns, only values. So, either:
- 使用尽可能多的命名查询排序
- 将排序字符串连接到查询字符串
- 使用条件查询
这篇关于Hibernate 命名查询 Order By 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文