Resultados no Hibernate

0 respostas
Guto_Magalhaes

Pessoal, é o seguinte: eu estou tentando fazer paginação no hibernate, e para isso estou utilizando o setFirstResult() e setMaxResult(). Mas esta dando a exception abaixo. Porem, se eu deixar apenas a setFirstResult, ele nao da problema. Por favor, me ajudem.

java.sql.SQLException: Parameter index out of range (3 > number of pa

rameters, which is 2).

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)

 37 more

20/08/2007  09:55:28,593 MSG - Operation Finished

Aqui vai o source:

public Collection loadClient(String id, String nome)

{

Session session = factory;

Collection c = new ArrayList();
if(session != null)
 {

      Criteria criteria = session.createCriteria(ClientEntity.class);
      
      if((id != null) && (!id.equals("")))
  {				  
       criteria.add(Expression.eq(CdEntity.FIELD_TB_ID,  Integer.parseInt(idGenre)));
       }
      
      if((nome != null) && (!nome.equals("")))
  {
	criteria.add(Expression.like(ClientEntity.FIELD_TB_NOME, singer+"%"));			  
   }

       criteria.setFirstResult(0);
       criteria.setMaxResult(5);

      c = criteria.list();

}

}

Obrigado

Criado 20 de agosto de 2007
Respostas 0
Participantes 1