2012-05-29 2 views
10

は、私はこのような私のHQLクエリを実行します:HQLでorder byを使用するにはどうすればよいですか?

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+
を認識していない私は、ORDER BY句を必要としています。

+2

は、あなたがなり「DESCが」No – oers

答えて

18

あなたはHSQLクエリ内の「順」配置する必要が表示されますが、スペースと:

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

、「DESC」の前にスペースをSHOLD欠けているように思えます、 – AFF

+0

エラー:org.hibernate.hql.ast.QuerySyntaxException:予期しないトークン:1の近くの注文 – AFF

+0

私はこのクエリを試してみました:クエリqueryPayment = sixSession.createQuery( "Payment from where vcode =:p_Vcode or "+ order +" desc ") エラー:Hibernateコアセッション/トランザクションインジェクションを使用してアクションを呼び出すエラー org.hibernate.hql.ast.QuerySyntaxException:予期しないトークン:1行目、127列目のorder [from information.Payment where vcode =:p_Vcodeまたは(Installment_Vcode =:installmentVcodeおよびpayment_date>:pdate)vcode descでvcode順に並べ替え] at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxExc – AFF

関連する問題