adsurbum
adsurbum

Reputation: 3177

strange exception on named parameter for native query in hibernate

I have a query

select ... from x join y on ..
where ... and :age between y.min and y.max

But when executing the query with hibernate i receive

org.hibernate.QueryParameterException: could not locate named parameter [age]

What is wrong?

Upvotes: 0

Views: 747

Answers (2)

Jeshurun
Jeshurun

Reputation: 23186

Since you haven't posted the actual query, my inference from your snippet is that you have the :age parameter in the wrong place in the query. The syntax for a query's where clause is column_name operator value so what you should have in place of :age is the actual column name of one of your tables. What you are probably trying to do is y.min >= :age and y.max <=:age.

Upvotes: 2

Kshitij
Kshitij

Reputation: 8614

check your java code if you have passed "age" properly. Possibly you might have missed it, or maybe misspelled it.

It will be good if you share you java side code also.

Upvotes: 0

Related Questions