Hello to all, I'm trying to do a search using this script:
Code:
Session sessao = (Session) HibernateUtil.sessionFactory.openSession();
Criteria criteria = sessao.createCriteria(Gato.class);
criteria.add(Restrictions.like ("nome", "%b%"));
criteria.setMaxResults(5);
List cats = (List) criteria.list();
for (Iterator it = ((java.util.List) cats).iterator(); it.hasNext();){
Gato gato = (Gato) it.next();
System.out.println(gato.getNome());
}
sessao.close();
At least, I thought there would be no problem, but it's returning this error:
Code:
22:58:08,811Exception in thread "main" java.lang.ClassCastException: java.util.ArrayList
at teste.movimentos.GatoAcao.main(GatoAcao.java:131)