I'm trying to use the setMaxResults() with a named query and it keeps generating an error. I'm using Hibernate 3.1 with MSSQL Server. Does anyone have any suggestions. Thank you for the assist.
//begin error
8425 [RMI TCP Connection(4)-10.11.12.199] INFO : could not bind value '1' to parameter: 3; Invalid parameter index 3.
(IntegerType:91)
8425 [RMI TCP Connection(4)-10.11.12.199] WARN : SQL Error: 0, SQLState: 07009 (JDBCExceptionReporter:71)
8425 [RMI TCP Connection(4)-10.11.12.199] ERROR: Invalid parameter index 3. (JDBCExceptionReporter:72)
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at com.cid.zeugmaruntime.dao.hibernate.ResultDaoImpl.getMoreResult(Unknown Source)
at com.cid.zeugmaruntime.result.ResultImpl.getMoreResult(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Invalid parameter index 3.
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setInt(JtdsPreparedStatement.java:495)
at com.mchange.v2.c3p0.impl.NewProxyCallableStatement.setInt(NewProxyCallableStatement.java:2732)
at org.hibernate.type.IntegerType.set(IntegerType.java:41)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:1748)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 19 more
8440 [RMI TCP Connection(4)-10.11.12.199] INFO : could not execute query (ResultDaoImpl:?)
//end error
//start code
try {
Session session = getSession();
logger.info("got a session");
Transaction tx = session.beginTransaction();
Query queryObject = session.getNamedQuery("uiSearchMoreResults");
queryObject.setInteger("NodeId", crit.getNodeId());
queryObject.setString("Filter", crit.getFilter());
queryObject.setInteger("ClassifyId", crit.getClassifyId());
queryObject.setFirstResult(0);
queryObject.setMaxResults(10);
List list = queryObject.list();
tx.commit();
HibernateUtil.closeSession();
return list;
} catch (HibernateException e) {
e.printStackTrace();
logger.info(e.getMessage());
List list = (List)new ArrayList();
return list;
}
//end code
|