Hi there,
I'm migrating some of my hql-statements to Criterias now I'm figuring one problem: The entity property is type Integer but I need a like with wildcards search, so in hql I do
session.createQuery("from P1 where id like :id").setString("id", "%"+s+"%")
No problem at all, Hibernate casts String to Integer.
If I try this in Criteria, I only get a ClassCastException
String cannot be cast to Integer
Criteria crit = sessionFactory.getCurrentSession().createCriteria(P1.class);
crit.add(Restrictions.like("id",s)).addOrder(Order.asc("id")).setMaxResults(maxResults);
Why hibernate handles this both situations differently?