I have a namedQuery thru which I pass 2 parameters like below,
ArrayList idName= new ArrayList();
idName.add(id); --int
idName.add(ABC); --String
and I pass this object to namedQuery as follows:
return getHibernateTemplate().findByNamedQuery("findIDAndName", idName);
and my hbm.xml has this query,
<sql-query name="findIDAndName">
<return alias="IdNamePmt" class="com.app.Grp.model.IdNamePmt"/>
<![CDATA[select * from PMT.CSE_NME_VW where PMT_ID=? and PMT_NAME=?]]>
</sql-query>
When i run the application I get the below error:
org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [[7, ABC]] [select * from PMT.CSE_NME_VW where PMT_ID=? and PMT_NAME=?]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:367)
at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:228)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:172)
I have passed 2 parameters and my 'where' clause also expects 2 parameters. What is wrong? any examples highly appreciated?