2222package org .apache .cayenne .exp .parser ;
2323
2424import java .io .IOException ;
25- import java .io .PrintWriter ;
2625import java .util .Collections ;
2726import java .util .List ;
2827import java .util .Map ;
2928
30- import org .apache .cayenne .CayenneRuntimeException ;
3129import org .apache .cayenne .ObjectId ;
3230import org .apache .cayenne .Persistent ;
3331import org .apache .cayenne .exp .Expression ;
@@ -88,7 +86,7 @@ protected static void encodeScalarAsEJBQL(List<Object> parameterAccumulator, App
8886 }
8987
9088 if (scalar instanceof Integer || scalar instanceof Long || scalar instanceof Float || scalar instanceof Double ) {
91- out .append (scalar . toString ( ));
89+ out .append (numericToString (( Number ) scalar ));
9290 return ;
9391 }
9492
@@ -139,6 +137,8 @@ protected static void appendScalarAsString(Appendable out, Object scalar, char q
139137 Enum <?> e = (Enum <?>) scalar ;
140138 out .append ("enum:" );
141139 out .append (e .getClass ().getName ()).append ("." ).append (e .name ());
140+ } else if (scalar instanceof Number ) {
141+ appendAsEscapedString (out , numericToString ((Number )scalar ));
142142 } else {
143143 appendAsEscapedString (out , String .valueOf (scalar ));
144144 }
@@ -148,6 +148,15 @@ protected static void appendScalarAsString(Appendable out, Object scalar, char q
148148 }
149149 }
150150
151+ protected static String numericToString (Number number ) {
152+ if (number instanceof Long ) {
153+ return number + "L" ;
154+ } else if (number instanceof Float ) {
155+ return number + "f" ;
156+ }
157+ return String .valueOf (number );
158+ }
159+
151160 /**
152161 * Utility method that prints a string to the provided Appendable, escaping special characters.
153162 */
0 commit comments