2011-08-06 17 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());