bestlong/krank

Use of Aggregate functions and String functions in Criteria search

Opened this issue · 0 comments

Problem:
Example:
List<Charger> chargerList = chargerService.getDao().find(
join(joinFetch("o.chargerPointList",true,"cpl")),
containsLike("cpl.cpNumber", true, "3222"),
containsLike("lower(o.address.city)", true, "lower(oregon)"),
containsLike("lower(o.address.street)", true, "lower(wallstreet)"),
containsLike("o.address.streetNumber", true, "112"));

Expected would be to get chargerList but I debugged it and the process of
query creation is build without knowing of string functions or any other
functions supported in jpql.
The outcome is expected: 
10:34:51,612 ERROR ErrorCounter : line 1:168: unexpected token: (

The generated query string:
SELECT  o FROM Charger o  join fetch o.chargerPointList cpl WHERE 
cpl.cpNumber LIKE :cpl_cpNumber  AND  lower(o.address.city) LIKE
:lower(o_address_city)  AND  lower(o.address.street) LIKE
:lower(o_address_street)  AND  o.address.streetNumber LIKE
:o_address_streetNumber 

The problem is this: 
:lower(o_address_city) it should be: lower(:o_address_city)

What version of the product are you using? On what operating system?
crank - 1.0.1
Windows XP SP2

Please provide any additional information below.
I was looking through examples in crank-crud, but I didnt found any
solution which would influence the query generation knowing about function.

One solution would be to create NamedQueries but this solution is not
suitable for filtering purposes.
With 3 filter properties you would have to create 6 NamedQueries to cover
all possibilities of user input.

It would be very helpful to have this functionality because of crank's
great criteria search, filtering and paging functionality.
Thx

Original issue reported on code.google.com by jano.p...@gmail.com on 7 May 2009 at 8:58