public interface QueryResult<T> extends Iterable<T>, AutoCloseable
A QueryResult
instance must always be closed after its use.
Here is a code sample benefiting from the automatic closing provided by
AutoCloseable
and its associated try
-with-resources notation:
Query<Tuple> query = dataset.createQuery("SELECT id, name FROM customer");
try (QueryResult<Tuple> result = query.getResult())
{
for (Tuple t : result)
{
Integer id = t.get(0, Integer.class);
String name = t.get(1, String.class);
...
}
}
A QueryResult
instance is not thread-safe and
it must be used only by the thread that created it.
If the table is concurrently updated, the rules specified by Query snapshot isolation apply.
Query.getResult()
,
Query snapshot isolationModifier and Type | Method and Description |
---|---|
void |
close() |
List<String> |
getFieldNames()
Returns the names of the fields in the result
|
List<Class<?>> |
getFieldTypes()
Returns the types of the fields in the result
|
forEach, iterator, spliterator