void setResultClass(
Class cls
)
If there are multiple result expressions, the result class must be able to hold all elements of the result specification or a JDOUserException is thrown.
If there is only one result expression, the result class must be assignable from the type of the result expression or must be able to hold all elements of the result specification. A single value must be able to be coerced into the specified result class (treating wrapper classes as equivalent to their unwrapped primitive types) or by matching. If the result class does not satisfy these conditions, a JDOUserException is thrown.
A constructor of a result class specified in the setResult method will be used if the results specification matches the parameters of the constructor by position and type. If more than one constructor satisfies the requirements, the JDO implementation chooses one of them. If no constructor satisfies the results requirements, or if the result class is specified via the setResultClass method, the following requirements apply:
- A user-defined result class must have a no-args constructor and one or more public
set
orput
methods or fields. - Each result expression must match one of:
- a public field that matches the name of the result expression and is of the type (treating wrapper types equivalent to primitive types) of the result expression;
- or if no public field matches the name and type, a public
setor if neither of the above applies,a public method must be found with the signature
void put(Object, Object)
. During processing of the results, the first argument is the name of the result expression and the second argument is the value from the query result.
set
- Parameters:
cls
- the result class
- Since:
- JDO 2.0