Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.2.M1
-
None
Description
The "toEJBQL()" method on the Expression object works well for some cases, but fails where parameter types are employed where there is no EJBQL literal that can be used to serialize the object as a string in the resultant EJBQL string.
An obvious case of this is the use of a Date object. Take the example of a comparison between an object path and a date parameter. The current code is outputting something like;
(a.something.createTimestamp > 25 Mar 2014 12:23:34)
This "toString" on the Date object does not generate valid EJBQL and as far as I am able to ascertain, there is no timestamp literal in EJBQL. For this reason, the "toEJBQL()" method on Expression is able to generate broken EJBQL strings.
My solution to this will be to keep the existing "toEJBQL()" method, but have that method fail with a runtime exception if it encounters a situation in which it is not able to serialize to EJBQL correctly. Another method "toEJBQL(List<Object> parameterAccumulator)" will be provided. This new method will populate the parameter accumulator each time it encounters a parameter that it is not able to express as a literal and instead it will use a positional parameter in the EJBQL string. The caller can then use the 'captured' parameters to feed back into the EJBQLQuery object.