I need to create a criteria using a like restriction on a numeric column.
Users need to filter a transactions list, and sometimes all they know is the last 4 digits of its id.
I created the DetachedCriteria and tried a few approaches with no luck
Code:
// (...)
DetachedCriteria c = DetachedCriteria.forClass(getDomainClass());;
c.add(Restrictions.like("transactionId", 42));
// or
c.add(Restrictions.like("transactionId", "%42%"));
// or
c.add(Restrictions.like("str(transactionId)", "%42%"));
// (...)
List l = getHibernateTemplate().findByCriteria(c);
// (...)
Any idea how I can achieve that using Criteria (not HQL)
Thanks for your time