I have to do
Restrictions.like("sequenceNo", "%" + Integer.valueOf(sequenceNo.trim()) + "%")
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
You cannot add Criteria`s property restrictions for the purpose, as during fetching, property value specifiedwould be casted according to the 'field type' specified in Entity class.
However, a solution would be using SQLRestriction of criteria, to by pass casting. I have tested and this works.
yourDetachedCriteriaObj.add(Restrictions.sqlRestriction(" sequenceNo LIKE '%"+yourSequenceNumToSearch+"%' "));
To get list you would do like below
List ls = yourDetachedCriteriaObj.getExecutableCriteria(yourSession).list(); // iterate over list or do whatever.