{"id":39,"date":"2008-08-13T18:19:28","date_gmt":"2008-08-13T18:19:28","guid":{"rendered":"http:\/\/shirishranjit.com\/blog1?page_id=39"},"modified":"2018-01-07T09:55:33","modified_gmt":"2018-01-07T14:55:33","slug":"orghibernatequeryparameterexception-could-not-locate-named-parameter","status":"publish","type":"page","link":"https:\/\/shirishranjit.com\/blog1\/java-stuff\/java-persistence-entitymanager-persist-v-s-merge\/orghibernatequeryparameterexception-could-not-locate-named-parameter","title":{"rendered":"org.hibernate. QueryParameterException: could not locate named parameter"},"content":{"rendered":"<div class=\"snap_preview\">When you query a database in Hibernate using <strong>NamedQuery<\/strong> you may run into this error<strong>org.hibernate.QueryParameterException: could not locate named parameter [parm1]<\/strong>. This error is due to the fact that  you are either trying to set a parmeter to the query which infact doesn<span class=\"__mozilla-findbar-search\" style=\"padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;\">&#8216;<\/span>t exist in your query. For exampleyou are trying to do<\/p>\n<p>query.setParameter(parm1, new Long(parm1Value));<\/p>\n<p>whereas, in query there is no parameter like parm1<\/p>\n<p>i.e. query might be just from Item item<\/p>\n<p>Or you might be committing some spelling mistake in your code<\/p>\n<p>Eg. query.setParameter(&#8216;pram1&#8217;, new Long(parm1Value));<\/p>\n<p>and query is from Item item item.desc like :parm1<\/p>\n<p>Do note that your parameter name in Java Class is misspelt as pram1 instead of parm1.<\/p>\n<\/div>\n<div class=\"twttr_buttons\"><div class=\"twttr_twitter\">\n\t\t\t\t\t<a href=\"http:\/\/twitter.com\/share?text=org.hibernate.+QueryParameterException%3A+could+not+locate+named+parameter\" class=\"twitter-share-button\" data-via=\"\" data-hashtags=\"\"  data-size=\"default\" data-url=\"https:\/\/shirishranjit.com\/blog1\/java-stuff\/java-persistence-entitymanager-persist-v-s-merge\/orghibernatequeryparameterexception-could-not-locate-named-parameter\"  data-related=\"\" target=\"_blank\">Tweet<\/a>\n\t\t\t\t<\/div><div class=\"twttr_followme\">\n\t\t\t\t\t\t<a href=\"https:\/\/twitter.com\/shiranjit\" class=\"twitter-follow-button\" data-size=\"default\"  data-show-screen-name=\"false\"  target=\"_blank\">Follow me<\/a>\n\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/shirishranjit.com\/blog1\/java-stuff\/java-persistence-entitymanager-persist-v-s-merge\/orghibernatequeryparameterexception-could-not-locate-named-parameter\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":901,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-39","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/39"}],"collection":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":7,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/39\/revisions"}],"predecessor-version":[{"id":1666,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/39\/revisions\/1666"}],"up":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/901"}],"wp:attachment":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/media?parent=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}