Package com.sap.cds
Interface Result
-
- All Superinterfaces:
Iterable<Row>
,JSONizable
public interface Result extends Iterable<Row>, JSONizable
Represents the result data returned by theCdsDataStore
.Result
can be serialized to JSON and accessed as anIterable
ofMap
or in a typed way via an accessor interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
batchCount()
Returns the number of batches.Optional<Row>
first()
Returns the first row.<T> Optional<T>
first(Class<T> type)
Returns the first row mapped to the giventype
.long
inlineCount()
Returns the total number of root entities matching the query as requested bySelect.inlineCount()
.List<Row>
list()
Returns a list of the result rows.<T> List<T>
listOf(Class<T> type)
Returns a list of the result rows mapped to the giventype
.long
rowCount()
Returns the number of rows affected or returned by the query.long
rowCount(int batch)
Returns the number of rows affected or returned by the query with the given batch index.CdsStructuredType
rowType()
Returns the row type of this result.Row
single()
Returns the single row.<T> T
single(Class<T> type)
Returns the single row mapped to the giventype
.Stream<Row>
stream()
Returns a sequentialStream
of the result rows.<T> Stream<T>
streamOf(Class<T> type)
Returns a sequentialStream
of the result rows mapped to the giventype
.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface com.sap.cds.JSONizable
toJson
-
-
-
-
Method Detail
-
single
Row single()
Returns the single row.- Returns:
- a
Row
- Throws:
EmptyResultException
- if the result is emptyNonUniqueResultException
- if the result contains more than one row
-
single
<T> T single(Class<T> type)
Returns the single row mapped to the giventype
.- Type Parameters:
T
- the return type- Parameters:
type
- the type the row is mapped to- Returns:
- a row mapped to
T
- Throws:
EmptyResultException
- if the result is emptyNonUniqueResultException
- if the result contains more than one row
-
first
<T> Optional<T> first(Class<T> type)
Returns the first row mapped to the giventype
.- Type Parameters:
T
- the type of theOptional
- Parameters:
type
- the type the row is mapped to- Returns:
- an
Optional
row mapped toT
-
stream
Stream<Row> stream()
Returns a sequentialStream
of the result rows.- Returns:
- a
Stream
of rows
-
streamOf
<T> Stream<T> streamOf(Class<T> type)
Returns a sequentialStream
of the result rows mapped to the giventype
.- Type Parameters:
T
- the type of theStream
- Parameters:
type
- the type the result rows are mapped to- Returns:
- a
Stream
of the giventype
-
listOf
<T> List<T> listOf(Class<T> type)
Returns a list of the result rows mapped to the giventype
.- Type Parameters:
T
- the type of theList
- Parameters:
type
- the type the result rows are mapped to- Returns:
- a list of the given
type
-
rowType
CdsStructuredType rowType()
Returns the row type of this result.- Returns:
- the row type
-
rowCount
long rowCount()
Returns the number of rows affected or returned by the query. In case of a batch query the sum over all batch row counts.- Returns:
- the row count, -1 if undefined
-
rowCount
long rowCount(int batch)
Returns the number of rows affected or returned by the query with the given batch index.- Parameters:
batch
- the batch index- Returns:
- the row count of the batch, -1 if undefined
- Throws:
IndexOutOfBoundsException
- if the batch index is out of range
-
batchCount
int batchCount()
Returns the number of batches.- Returns:
- the number of batches, -1 if undefined
-
inlineCount
long inlineCount()
Returns the total number of root entities matching the query as requested bySelect.inlineCount()
.- Returns:
- the row count, -1 if undefined
-
-