开发者

named parameters in a subquery in hibernate

开发者 https://www.devze.com 2023-03-26 02:15 出处:网络
how can I pass a parameter to a subquery in hibernate? I am trying this but I get an exception that :currentDate does not exist as a named parameter in (...[query]...) even though the query clearly sh

how can I pass a parameter to a subquery in hibernate? I am trying this but I get an exception that :currentDate does not exist as a named parameter in (...[query]...) even though the query clearly shows :currentDate in it

The query looks like

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()


Don't use colons when you set parameters.

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

精彩评论

暂无评论...
验证码 换一张
取 消