SQLNamedQuery in Spring hibernate Error <p>Following is the my code.</p> <pre><code>&lt;sql-query name="findPreviousQuestionnarieId"&gt; &lt;return-scalar column="questionId" type="long" /&gt; &lt;![CDATA[select max(B.Questionnaire_Id) as questionId from dbo.Rme_Questionnaire_Answer_Header A,Rme_Questionnaire_Answer_Header B where A.Questionnaire_Id = : currentQuesId and B.Questionnaire_Id &lt; A.Questionnaire_Id and A.Questionnaire_Code = B.Questionnaire_Code]]&gt; &lt;/sql-query&gt; </code></pre> <p>Error while starting server is,</p> <blockquote> <p>Errors in named queries: com.mmm.rme.core.domain.evaluation.QuestionnaireResponseHeader.findPreviousQuestionnarieId</p> </blockquote> <p>the method i am using to access is,</p> <pre><code>results = this.getHibernateTemplate().findByNamedParam(namedQuery, paramName, value); </code></pre>