Search code examples
hibernatecriteria

Criterion Restrictions.like and numbers and dates


I'm using Hibernate over mySQL. In mySQL you can put LIKE in queries even on number (like double) parameters and dates, for example you can write:

select * from sillytable where field like "3.33%"

and this will work. The problem is that I can't do this in criterion using Restrictions.like, in fact it throws an exception says that it can't cast a String to a Date or Double.

How can I do this with it?


Solution

  • I found that the only good solution that did what I meant to do was using HQL. There is no clear way to do this in Criteria