I using Named native query in orm.xml.
I wrote a query to fetch Ids from a particular table. Since I just want to return the result, I wrote a dummy result set mapping.
I get the following error :
could not locate named parameter [1]
But this way of declaring parameters works fine while we write the query in Java file using String concatenation. What might be the problem ?
Here is the part of my orm.xml
<named-native-query name="transactionIDs" result-set-mapping="dummy">
<query>
SELECT txn_master.id FROM txn_master txn_master
LEFT JOIN transaction txn_detail ON txn_detail.master_id = txn_master.id
WHERE txn_detail.created between ? AND ?
</query>
</named-native-query>
<sql-result-set-mapping name="dummy">
<column-result name="bla" />
</sql-result-set-mapping>
But I get the error :
16:46:54,933 ERROR [STDERR] java.lang.IllegalArgumentException:
org.hibernate.QueryParameterException: could not locate named parameter [1]
16:46:54,933 ERROR [STDERR] at
org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:176)
16:46:54,933 ERROR [STDERR] at
org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:231)