Description:
|
DB2Dialect uses AnsiTrimEmulationFunction for the "trim" function. This attempts to use the following SQL:
select replace(replace(ltrim(rtrim(replace(replace(customer0_.NAME, ' ', '${space}$'), ?, ' '))), ' ', ?), '${space}$', ' ')
This fails w/ the following error:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-418, SQLSTATE=42610, SQLERRMC=null, DRIVER=4.13.80
Allowing the dialect to use the "trim(?1 ?2 ?3 ?4)" instead results in:
select trim(BOTH ? from customer0_.NAME) as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=?
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-123, SQLSTATE=42601, SQLERRMC=strip-or-trim-char;SYSIBM.TRIM, DRIVER=4.13.80
Neither method is attempting to use a literal.
The 418 error code page states that:
{quote} The statement cannot be executed because a parameter marker has been used in an invalid way.
Parameter markers cannot be used:
In the SELECT list as the sole argument of a scalar function. In a concatenation operation. In the string expression of an EXECUTE IMMEDIATE SQL statement. In a result-expression in any CASE expression when all the other result-expressions are either NULL or untyped parameter markers. In a key-expression of an index definition.
Untyped parameter markers cannot be used:
As an argument to an XMLQUERY function. As an argument to an XMLEXISTS predicate. {quote}
Unless I'm missing something, the queries appear to be meeting the rules.
See CriteriaCompilingTest#testTrim for a test case.
|