The second table shows the return types for each method in the Data interface that you can use to query 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 |
queryXxx() methods | L<M<S,O>> | L<T> | M<S,O> | M<S,O>[] | <T> | <T>[] | I<M<S,O>> | I<T> |
---|---|---|---|---|---|---|---|---|
Data.queryArray() | X | |||||||
Data.queryArray() with returnClass | X | |||||||
Data.queryList() | X | |||||||
Data.queryList() with returnClass | X | |||||||
Data.queryIterator() | X | |||||||
Data.queryIterator() with returnClass | X | |||||||
Data.queryFirst() | X | |||||||
Data.queryFirst() with returnClass | X |
Description of return types
If more than one row qualifies, the value from the first row is returned.
Any underlying database ResultSet object is closed.
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, the value from the first row is returned.
Any underlying database ResultSet object is closed.
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.
When you use a method of the Data interface, do not specify a generic <T> class that is any of the <primitive Java type>.class classes, such as int.class.
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 = data.queryFirst("select ...", int.class, p);because the definition of the queryFirst() method is this:
<T> T data.queryFirst(String sql, Class<T> returnType, Object... params);
Integer tCount = data.queryFirst("select ...", Integer.class, p);