0

following is my code to call the database to find the substring "ello".

String queryString = "from ContentItem where singerName = '%"+searchString+"%' OR  songName = '%"+searchString+"%'";
System.out.println(queryString);
Query query = session.createQuery(queryString);
return query.list();  

the string output is

from ContentItem where singerName = '%ello%' OR songName = '%ello%'

it says Unexpected Token for %. How to make this possible to search substring inside those columns?

I'm working Hibernate inside Tapestry.

1 Answer 1

1

the equals (=) operator does not work with wildcards. You need to use like (or ilike).

eg

SELECT * FROM table WHERE column like '%abc%';

see this document for more info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.