lowercase - Grails lower() in query not working -
let's have code this:
def c = account.createcriteria() def results = c { between("balance", 500, 1000) eq("branch", "london") or { like("holderfirstname", "fred%") like("holderfirstname", "barney%") } maxresults(10) order("holderlastname", "desc") }
i want use lower() function transforming data lower case
def c = account.createcriteria() def results = c { between("balance", 500, 1000) eq("branch", "london") or { like("lower(holderfirstname)", "fred%") like("lower(holderfirstname)", "barney%") } maxresults(10) order("holderlastname", "desc") }
my code doesn't work. correct syntax? have problem umlauts don't want use ilike
to use database functions in criteria need use sqlrestriction()
add's restrictions directly generated sql.
def c = account.createcriteria() def results = c.list { ... sqlrestriction("lower(holder_first_name) '%%'") }
note use column name, , not attribute name.
Comments
Post a Comment