PostgreSQL like + Hibernate problem
- by Marat_Galiev
Hi all.
I want to do search in PostgreSQL for INTEGER based columns.
if (!sSearch.isEmpty()) {
sSearch = sSearch.replaceAll("[^a-zA-Z0-9]", "_").toLowerCase();
String[] search = sSearch.split(" ");
sWhere = " ";
for (NewsColumns column : NewsColumns.values()) {
for (String s : search) {
sWhere += "lower(" + column + "::TEXT) LIKE '%" + s + "%' OR ";
}
}
sWhere = sWhere.substring(0,sWhere.length()-3);
}
Ok, I want to convert INT value to String before search, with '::TEXT' expression.
But after executing I'm getting:
org.hibernate.QueryException: Not all named parameters have been set: [:TEXT] [select * from news WHERE lower(ID::TEXT) LIKE '%5%' Exception.
Looks like hibernate parse my convert exp as parameter.
Any help is appreciated.
Thanks.