Version 1.0 introduces a "new object expression" (implemented by the
NewObjectExpression class). The new object expression can be used anywhere an expression can be used. It allows (as you might expect ;) a new object to be created. Additionally
setters can be called to specify certain values on the newly created object. (A
setter is basically a single argument Java method or field, any method or field can be used, if no matching field is found then a "set" method is looked for in a similar way to how
Accessors work)
The general syntax for the new object expression is:
new Fully-Qualified Classname ( [ Expression [ , Expression ]* ] ) { Expression -> Setter [ , Expression -> Setter ]* }
For example:
SELECT new java.io.File (parentFile) { lastModified -> lastModified }
FROM java.io.File
Now because any expression can be used for the setter value/constructor arguments it means that new object expressions can be used. The constructor to use to create the object is selected by the types of the arguments.
Note: when only a single "new object" is defined in the
SELECT clause then instead of a List of Lists being returned, only a List of the specified objects will be returned. In other words it is equivalent of using
* but creating new objects instead.