org.hibernate. QueryParameterException: could not locate named parameter

When you query a database in Hibernate using NamedQuery you may run into this errororg.hibernate.QueryParameterException: could not locate named parameter [parm1]. This error is due to the fact that you are either trying to set a parmeter to the query which infact doesnt exist in your query. For exampleyou are trying to do

query.setParameter(parm1, new Long(parm1Value));

whereas, in query there is no parameter like parm1

i.e. query might be just from Item item

Or you might be committing some spelling mistake in your code

Eg. query.setParameter(‘pram1’, new Long(parm1Value));

and query is from Item item item.desc like :parm1

Do note that your parameter name in Java Class is misspelt as pram1 instead of parm1.

Leave a Reply