This question already has an answer here:
- Using LIKE % in Hibernate 3 answers
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'
den 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);
You can use criteria for using like
It will give you the list of string which start by alpha-bate 'a'.
Change your query to this:
The above thing worked for me :)
Change to
This way