0

如何在休眠中将参数传递给子查询?我正在尝试这个,但我得到一个例外,即 :currentDate 在 (...[query]...) 中不作为命名参数存在,即使查询清楚地显示 :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()
4

1 回答 1

2

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

q.setDate("currentDate", new Date());
于 2011-08-06T03:39:02.387 回答