如何使用HQL中的参数在WHERE中创建使用CASE语句?

时间:2014-04-29 16:08:58

标签: java hibernate hql

伙计们感谢时间和帮助

我使用case和参数进行HQL查询,当我设置参数

时出现错误

我的查询是:

SELECT 
IC.Sources, 
IC.Total, 
IC.Destination, 
IC.Where, 
ICP.Date, 
ICP.filedirectory, 
ICP.filename 
FROM IcmA AS IC, IcmProc AS ICP
WHERE IC.uniqueid = ICP.uniqueid
AND IC.Sources = :Num OR IC.Destination= :Num
AND CASE 
WHEN LENGTH(IC.Sources) = 1 OR LENGTH(IC.Destination) = 1 THEN
:NBalance
WHEN LENGTH(IC.Sources) > 1 OR LENGTH(IC.Destination) > 1 THEN
:NBalance
ELSE
:NBalance
END = :NBalance
AND(DATE_FORMAT(ICP.Date, '%Y/%m/%d') >= :fDate AND DATE_FORMAT(ICP.Date, '%Y/%m/%d') <= :tDate) ORDER BY ICP.Date DESC

错误:

org.hibernate.hql.ast.tree.ParameterNode cannot be cast to org.hibernate.hql.ast.tree.SelectExpression>
java.lang.ClassCastException: org.hibernate.hql.ast.tree.ParameterNode cannot be cast to org.hibernate.hql.ast.tree.SelectExpression

0 个答案:

没有答案