SELECT name FROM Countries WHERE name LIKE '%someValue%';
Country
with an attribute name
, you would write it out as follows:
String searchExp = "find me"; Query qs = entity.createQuery("SELECT c.name FROM Country c WHERE UPPER(c.name) LIKE '%:val%'"); qs.setParameter("val",searchExp.toUpperCase());
The key here is to convert the right-side in code and then you can use the function
UPPER( )
for the left-side of the expression.
This was tested with MySQL and HSQLDB with EclipseLink. There was an article I found here which states that with MySQL 5.1 onward you don't need to use the
LOWER
function, but I have not verified this yet (nor found the collaborating evidence on MySQL's website). Running against my test system in HSQLDB (in memory) it did not find the results in my unit tests.
1 comment:
Nice!
Post a Comment