Hello people. I have a problem: I'm try to make a query using the criteria api. I need to make paging, and for this I use te functions setFirstResult()
and setMaxResults(), and after I add the criteria in a collection, a exception is generated. The source its below:
Collection c = new ArrayList();
Criteria criteria = session.createCriteria(Entity.class);
criteria.setFirstResult(0);
criteria.setMaxResults(5);
c = criteria.list();
But when I execute it, the a SqlException is generated. The SqlException is below:
java.sql.SQLException: Parameter index out of range (2 > number of pa
rameters, which is 1).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2
715)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2
746)
at com.mysql.jdbc.PreparedStatement.setInt(PreparedStatement.java:2697)
at org.hibernate.loader.Loader.bindLimitParameters(Loader.java:1618)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1557)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2157)
Please, help me!!!
|