com.mysql.cj.xdevapi

## Interface FetchResult<T>

Type Parameters:
  `T` - the type of element returned from the query (doc or row)

All Superinterfaces:
  Iterable<T>, Iterator<T>

All Known Subinterfaces:
  DocResult, RowResult, SqlResult

    public interface FetchResult<T>
    extends Iterator<T>, Iterable<T>

A set of elements from a query command.

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`long` `count()` How many items are in this result? This method forces internal buffering of the entire result.
`List<T>` `fetchAll()` Create a list of all elements in the result forcing internal buffering.
`default T` `fetchOne()` Fetch the next element.
`default boolean` `hasData()` Does this result have data? This indicates that the result was produced from a data-returning query.
`default Iterator<T>` `iterator()` Create an iterator over all elements of the result.

### Methods inherited from interface java.util.Iterator

`forEachRemaining, hasNext, next, remove`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Method Detail

#### hasData

    default boolean hasData()

Does this result have data? This indicates that the result was produced from a data-returning query. It does not indicate whether there are more than 0 rows in the result.

Returns:
  true if has data

#### fetchOne

    default T fetchOne()

Fetch the next element.

Returns:
  element of type T

#### iterator

    default Iterator<T> iterator()

Create an iterator over all elements of the result.

Specified by:
  `iterator` in interface `Iterable<T>`
Returns:
  iterator over result items

#### count

    long count()

How many items are in this result? This method forces internal buffering of the entire result.

Returns:
  number of elements in result

#### fetchAll

    List<T> fetchAll()

Create a list of all elements in the result forcing internal buffering.

Returns:
  list of result elements

Copyright © 2016, 2025, Oracle and/or its affiliates.