As of version
1.9 you can create a list of expressions using
[] brackets.
For example:
SELECT *
FROM MyObject
WHERE findMin ([first, second, third, fourth]) > 1
In this case all the expressions between the
[ and
] will be placed together into an
ExpressionList (which is basically a wrapper around a
List).
The expression list can be used wherever a standard
expression is used. When the expression list is evaluated JoSQL will evaluate each expression in the list and return a list of the values.
Nested Lists
It is also possible to create nested lists, for example:
SELECT *
FROM MyObject
WHERE findMin ([first, [second, second2, second3], third, [fourth, fourth2]]) > 1
Use in Functions
To use lists in functions just use a
List as the argument type:
public double findMin (List nums)
When the function is called the expressions are evaluated and a list created with those values and passed to the function.
If you wish to have more control over the execution of the expressions however you should use a
ExpressionList or
Expression as the argument type:
public double findMin (Expression nums)
In this case JoSQL will just pass the expression list itself and you should then use:
getExpressions() to get the expressions to evaluate.
Use in SELECT Clause
SELECT [min, max]
FROM MyObject
Use in WHERE Clause function
SELECT *
FROM MyObject
WHERE findMin ([first, last]) = :value
Use in SELECT Clause for new Object creation
SELECT new java.util.ArrayList ([first, last])
FROM MyObject