>>-@Select--(--sql--=--"--SQL-statement--"--)-------------------> >--+--------------------------------------------------------------------------------------+--> '-@Handler--(--+-parameterHandler--=--class-name----------------------------------+--)-' +-resultHandler--=--class-name-------------------------------------+ +-resultHandler--=--class-name--,--parameterHandler--=--class-name-+ +-rowHandler--=--class-name----------------------------------------+ '-rowHandler--=--class-name--,--parameterHandler--=--class-name----' >--modifiers--return-type--method-name--(--+------------------------------------+--);->< | .-,------------------------------. | | V | | '---parameter-type--parameter-name-+-'
To understand the conventions that are used in the syntax diagram, see How to read syntax diagrams.
return-type: >>-+-Iterator<T>--------+-------------------------------------->< +-List<T>------------+ +-Map<String,Object>-+ +-T------------------+ '-T[]----------------'
The second table shows the possible return types for annotated methods that query in-memory collections.
Abbreviation | Meaning |
---|---|
I | Iterator |
L | List |
M | Map |
O | Object |
S | String |
T | Generic class, which can be a wrapper class for a primitive Java type, or a bean |
I<M<S,O>> | I<T> | L<M<S,O>> | L<T> | M<S,O> | M<S,O>[] | <T> | |
---|---|---|---|---|---|---|---|
@Select | X | X | X | X | X | X | X |
When you use an annotated method, do not specify that a @Select returns a primitive Java type, or an Array, List, or Iterator of a primitive Java type.
Information regarding SQL null values is lost whenever information queried from SQL is stored in a primitive Java type. Also, Java requires that a generic method that specifies generic <T> class of a <primitive Java type>.class must return an instance of the wrapper class that is appropriate for that primitive Java type.
int tCount = myGenericMethod( int.class );
where
this is the definition of myGenericMethod:<T> T myGenericMethod( Class<T> cl );
Integer tCount = myQuery.myGenericMethod( Integer.class );
Specifies that an Iterator object is returned, with each element corresponding to a row. The parameterized type T must be specified.
Iterators in pureQuery are of type ResultIterator. You must close them with the ResultIterator.close() method after you finish using them.
Specifies that a scalar or bean is returned. A scalar could be a wrapper such as Double, or a String, Date, or Timestamp.
If more than one row qualifies as a result of the query, the value from the first row is returned.
These parameters are matched with the parameter markers specified in the SQL statement according to the rules below. These parameters can be scalar types, bean classes, or Map objects. If the SQL uses the :name notation for parameter references, the first parameter-type must be a bean or a Map. The property names from the bean or Map object are used for matching with the :name occurrences in the SQL string.
At least one parameter that is an Iterator, Array, or iterable List is required so that pureQuery can identify the corresponding SELECT statement as a query over an in-memory collection. Reference this parameter in the FROM clause of the SELECT statement by using the syntax that is described in Parameter markers in the FROM clause of queries over in-memory Java collections.
If the SQL uses the ? notation for parameter markers, you can provide only scalar values.
If you use the ?n notation, the corresponding parameters must be scalar types (unless they are in the FROM clause, in which case they must be collections or Array objects).
If you use the ?n.name notation, the corresponding parameters must be either bean classes or Map objects. The ?n and ?n.name notations can be mixed in a single query, but cannot be mixed with stand-alone ? parameter markers.