Package com.sap.cds

Interface Result

All Superinterfaces:
Iterable<Row>, JSONizable

public interface Result extends Iterable<Row>, JSONizable
Represents the result data returned by the CdsDataStore. Result can be serialized to JSON and accessed as an Iterable of Map or in a typed way via an accessor interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of batches.
    Returns the first row.
    <T> Optional<T>
    first(Class<T> type)
    Returns the first row mapped to the given type.
    long
    Returns the total number of root entities matching the query as requested by Select.inlineCount().
    Returns a list of the result rows.
    <T> List<T>
    listOf(Class<T> type)
    Returns a list of the result rows mapped to the given type.
    long
    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.
    Returns the row type of this result.
    Returns the single row.
    <T> T
    single(Class<T> type)
    Returns the single row mapped to the given type.
    Returns a sequential Stream of the result rows.
    <T> Stream<T>
    streamOf(Class<T> type)
    Returns a sequential Stream of the result rows mapped to the given type.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface com.sap.cds.JSONizable

    toJson
  • Method Details

    • single

      Row single()
      Returns the single row.
      Returns:
      a Row
      Throws:
      EmptyResultException - if the result is empty
      NonUniqueResultException - if the result contains more than one row
    • single

      <T> T single(Class<T> type)
      Returns the single row mapped to the given type.
      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 empty
      NonUniqueResultException - if the result contains more than one row
    • first

      Optional<Row> first()
      Returns the first row.
      Returns:
      an optional Row
    • first

      <T> Optional<T> first(Class<T> type)
      Returns the first row mapped to the given type.
      Type Parameters:
      T - the type of the Optional
      Parameters:
      type - the type the row is mapped to
      Returns:
      an Optional row mapped to T
    • stream

      Stream<Row> stream()
      Returns a sequential Stream of the result rows.
      Returns:
      a Stream of rows
    • streamOf

      <T> Stream<T> streamOf(Class<T> type)
      Returns a sequential Stream of the result rows mapped to the given type.
      Type Parameters:
      T - the type of the Stream
      Parameters:
      type - the type the result rows are mapped to
      Returns:
      a Stream of the given type
    • list

      List<Row> list()
      Returns a list of the result rows.
      Returns:
      a list of Row
    • listOf

      <T> List<T> listOf(Class<T> type)
      Returns a list of the result rows mapped to the given type.
      Type Parameters:
      T - the type of the List
      Parameters:
      type - the type the result rows are mapped to
      Returns:
      a list of the given type
    • 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 by Select.inlineCount().
      Returns:
      the row count, -1 if undefined