2011-08-06 14 views
0

如何将参数传递给hibernate中的子查询?我试着这个,但我得到一个异常:即使查询清楚地显示:currentDate不存在作为(... [查询]中的命名参数):在休眠子查询中命名参数

查询看起来像

createQuery 
(
    "from mymodel where someid = :modelId and otherKey not in 
    (select c.otherKey from someOtherTable c where c.updateDate = :currentDate)" 
) 
.setLong(":modelId", someLongValue) 
.setDate(":currentDate", new Date()) 
.list() 

回答

1

设置参数时不要使用冒号。

q.setDate("currentDate", new Date());