Description:
|
For DB2 a warning message is generated by TempateRenderer which is not seen
DB2Dialect uses AnsiTrimEmulationFunction
for
other databases: WARN: HHH00174:Function template anticipated 3 arguments, but 2 arguments encountered
see test _org
the "trim" function
.
hibernate.ejb.criteria.CriteriaCompilingTest#testTrim_ for more details Also
This attempts to use
the
query created is different in case of DB2
following SQL
:
Hibernate:
select replace(replace(ltrim(rtrim(replace(replace(customer0_.NAME,' ','${space}$'),?,' '))),' ',?),'${space}$',' ')
as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=? fetch first 2 rows only
and finally it
This
fails
because of above warning
w/ the following error
:
javax
com
.
persistence
ibm
.
PersistenceException: org
db2
.
hibernate
jcc
.
exception
am
.
SQLGrammarException
SqlSyntaxErrorException
: DB2 SQL Error: SQLCODE=-
313
418
, SQLSTATE=
07001
42610, SQLERRMC=null, DRIVER=4.13.80
For other DBs same code generates following query and test passes
Allowing the dialect to use the "trim(?1 ?2 ?3 ?4)" instead results in
:
Hibernate:
select trim(BOTH ? from customer0_.NAME) as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=?
limit ?
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.
|