hi appfusers, in appfuse 2.x, i have a problem executing, the follow sentence java: [code] return getHibernateTemplate().findByNamedQuery("myquery",queryParams); [/code] throws the next exception: java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
if i change the code to: [code] return findByNamedQuery("myquery",queryParams); [/code] GenericDaoHibernate public method: public List<T> findByNamedQuery( String queryName, Map<String, Object> queryParams) { String []params = new String[queryParams.size()]; Object []values = new Object[queryParams.size()]; int index = 0; Iterator<String> i = queryParams.keySet().iterator(); while (i.hasNext()) { String key = i.next(); params[index] = key; values[index++] = queryParams.get(key); } the excepcion isn´t threw. All works well! Is this one a bug in getHibernateTemplate ? i think that the problem is the next definition [code]values[index++] = queryParams.get(key);[/(code] because in getHibernateTemplate the array definition doesn´t started in 1... started in 0 [code of HiberanteTemplate] public List findByNamedQuery(final String queryName, final Object[] values) throws DataAccessException { return (List) executeWithNativeSession(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query queryObject = session.getNamedQuery(queryName); prepareQuery(queryObject); if (values != null) { for (int i = 0; i < values.length; i++) { queryObject.setParameter(i, values[i]); } } return queryObject.list(); } }); } [/code of HiberanteTemplate] thanks