Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoiding % and _ in SQL predicate

Tags:

java

hazelcast

The following code to search a particulate data in the map is not working when the searchWord contains %,',_, etc

StringBuilder fullQuery= new StringBuilder().
                 append("Name like \'").append(searchWord).
                 append("%\'");

List<Person> persons = (List<Person>) personMap
                .values(new SqlPredicate(fullQuery));

How can I use those symbols for actual match.

like image 298
Kajal Avatar asked Feb 28 '26 01:02

Kajal


1 Answers

Hazelcast SQL like queries do not have Variable binding like Hibernate. You would have to do that on your own. You might want to store the statement in a constant and use String::format to replace variables.

like image 160
noctarius Avatar answered Mar 02 '26 14:03

noctarius