Java 如何在HQL中使用order by?

Java 如何在HQL中使用order by?,java,hql,Java,Hql,我想像这样执行我的HQL查询: Query queryPayment=sixSession.createQuery("from Payment where vcode=:p_Vcode or (Installment_Vcode=:installmentVcode and payment_date>:pdate) order byvcode."+order +"desc") .setParameter("p_Vcode", p_Vcode) .setPara

我想像这样执行我的HQL查询:

Query queryPayment=sixSession.createQuery("from Payment where vcode=:p_Vcode or (Installment_Vcode=:installmentVcode and payment_date>:pdate) order byvcode."+order +"desc")
        .setParameter("p_Vcode", p_Vcode)
        .setParameter("installmentVcode", installmentVcode)
        .setParameter("pdate", pdate);
但它不能识别
+订单+


我需要order by子句。

似乎您必须在HSQL查询中输入“order by”,但带有空格:

"from Payment where vcode=:p_Vcode or (Installment_Vcode=:installmentVcode and
payment_date>:pdate) order by vcode desc"

似乎您在“desc”之前缺少一个空格,应该是“desc”。错误是:org.hibernate.hql.ast.QuerySyntaxException:意外标记:第1行附近的订单我已尝试此查询:query queryPayment=sixession.createQuery(“从付款,其中vcode=:p_vcode=:分期付款vcode=:分期付款vcode和付款日期>:pdate)按vcode排序。“+order”+“desc”),错误是:使用Hibernate核心会话/事务注入org.Hibernate.hql.ast.QuerySyntaxException调用操作时出错:意外令牌:第1行第127列附近的订单[来自信息.付款,其中vcode=:p_vcode或(分期付款:分期付款vcode=:分期付款vcode和付款日期>:pdate)按vcode顺序按vcode顺序按vcode顺序]在org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException)中,改为从我的答案中执行查询。