Categories
concat hibernate hibernate-criteria java sql

Using Hibernate’s Criteria API, can I use concat with ilike restrictions?

Intuitively, what I want to do is something like this:

Restrictions.ilike("concat(user.firstName, ' ', user.lastName)",
text.toLowerCase() + "%")

However, I know that this won’t work, because concat(user.firstName, ' ', user.lastName) is not a property that Hibernate understands, even though this is what I would have typed in a regular SQL statement as part of the where clause.

Is there any easy way to make this where restriction with Hibernate Criteria API, or do I have to fall back on good-old HSQL?

Thanks