randomThought
randomThought

Reputation: 6393

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

Upvotes: 0

Views: 3003

Answers (1)

Alex Gitelman
Alex Gitelman

Reputation: 24722

Don't use colons when you set parameters.

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

Upvotes: 2

Related Questions