简体   繁体   中英

named parameters in a subquery in hibernate

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

设置参数时请勿使用冒号。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM