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()
Don't use colons when you set parameters.
q.setDate("currentDate", new Date());
精彩评论