Quote:
java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:397)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369)
at *****.common.util.HibernateDAO.listQuery(HibernateDAO.java:421)
at *****.common.util.HibernateDAO.listByConstraint(HibernateDAO.java:403)
at *****.common.util.HibernateDAO.listByConstraint(HibernateDAO.java:384)
at *****.clientmgmt.dao.ClientDAOImpl.getClient(ClientDAOImpl.java:104)
at *****.test.dao.ClientDAOTest.insertAndCheck(ClientDAOTest.java:189)
at *****.test.dao.ClientDAOTest.testInsertMutualFundClient(ClientDAOTest.java:333)
We're using Hibernate 3, and I'm making sure a subclass MutualFund is persisting with this JUnit test. Due to the above exception, it never gets past the 2nd line of the test's insertAndCheck method:
Code:
dao.insertClient( c );
Client c2 = dao.getClient( c.getUCN() );
When I drill down into our HibernateDAO.listQuery method, I see that the IndexOutOfBoundsException is occurring when setParameter is called:
Code:
for (int i = 0; i < params.length; i++) {
q.setParameter(i, params[i]);
}
There is one parameter in the params array. Since there is a lot of debate in forums online about whether Query.setParameter is 0 or 1-based, I tried this and get the same exception:
Code:
for (int i = 0; i < params.length; i++) {
int indexToSet = i + 1;
q.setParameter(indexToSet, params[i]);
}
By the way, insert does work, and I see new rows in the database, so the problem is just occurring when we're having Hibernate retrieve the new record. It seems like the exception message doesn't really relate to whatever is causing the problem. Any ideas? Thanks so much...