How to write a like query in HQL
hibernate, hql, java, sql-like
Solution
Change your query to this:
Query qry = session.createQuery("From RegistrationBean as rb where rb."+searchCriteria+" like ?");
qry.setString(0, "%"+searchField+"%");
Problem
I want to perform search for a particular string that is starting with a particular alphabet. So, for example if the starting alphabet is `'A'` then it should produce a result which will contain all the strings with alphabet `'A'`. How do I achieve this ? My query is as shown below: ``` Query qry = session.createQuery("From RegistrationBean as rb where rb."+searchCriteria+" like %?%"); qry.setString(0,searchField); ```