Hi there,
I'm trying to build a cirteria with a like restriction. The entity property is of type "Decimal" if I try this
Code:
session.createQuery("from P1 where id like :id").setString("id", "%"+s+"%")
this will work, sadly this is a hql query. My criteria looks like this
Code:
return sessionFactory.getCurrentSession().createCriteria(P1.class).add(Restrictions.like("pnr", "%" + s + "%")).list()
this isn't the whole cirteria, there are some more restrictions on it. Anyway with this I only recieve a ClassCastException
Code:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at org.hibernate.type.IntegerType.set(IntegerType.java:64)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1728)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1699)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
Why is this handled so different?