java.lang.Double
. Similarly, all expressions that provide a numeric result are represented as java.lang.Double
objects. This is a design choice to prevent certain issues that can arise, such as number compatibility, casting and accuracy. However JoSQL does not force functions to return an instance of java.lang.Double
(if a return value is necessary) so it is possible that the results of a query can contain a mix of number types.For example, defining the following function:
/** * Convert the passed in number to an integer. */ public int convert (Number o)
SELECT convert (12345), 12345, 1 + 1 FROM java.lang.Object LIMIT 1, 1
java.lang.Integer
, an instance of java.lang.Double
at index 1 and an instance of java.lang.Double
at index 2 (even though a java.lang.Short
would have sufficed).Care should be taken for this situation since it is very likely that a CCE could occur unless the results are dealt with as
java.lang.Number
objects, thus:List res = q.execute (myObjs); for (int i = 0; i < res.size (); i++) { List iRes = (List) res.get (i); for (int j = 0; j < iRes.size (); j++) { Number n = (Number) iRes.get (j); int v = n.intValue (); } }