That's not the case. I don't need to convert the
String text, I need to convert the database column
userId.
I have to tell criteria/Restrictions to, when its generates the sql query, it use CAST(userId as varchar), like so:
Code:
SELECT ... CAST(userId as varchar) as UserId, lastname ... FROM Users ... WHERE ...
Look at the code:
Code:
public List<User> listByCriteria(String text) {
text = addPercentSign(text);
Criteria criteria = session.createCriteria(User.class)
.add(Restrictions.disjunction()
.add(Restrictions.ilike("lastname", text))
.add(Restrictions.ilike("userId", text));
return criterio.list();
}
I do not need to convert
text because it is a String already, but
userId it is not!