Package jakarta.nosql

Interface QueryMapper.MapperQueryBuild

All Known Subinterfaces:
QueryMapper.MapperFrom, QueryMapper.MapperLimit, QueryMapper.MapperNameOrder, QueryMapper.MapperSkip, QueryMapper.MapperWhere
Enclosing interface:
QueryMapper

public static interface QueryMapper.MapperQueryBuild
Represents the last step of the query fluent API execution.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> List<T>
    Executes the query and returns the result as a List.
    <T> Optional<T>
    Executes the query and returns the result as a single element, wrapped in an Optional.
    <T> Stream<T>
    Executes the query and returns the result as a Stream.
  • Method Details

    • result

      <T> List<T> result()
      Executes the query and returns the result as a List.
      Type Parameters:
      T - the entity type
      Returns:
      the result of the query
      Throws:
      UnsupportedOperationException - If a NoSQL database does not support a specific operation or if the database does not support certain query conditions, an exception will be raised. For example, a wide-column may not support the OR operator, or a document database may not support the BETWEEN operator. The level of NoSQL database support for various conditions may vary depending on the database provider.
    • stream

      <T> Stream<T> stream()
      Executes the query and returns the result as a Stream.
      Type Parameters:
      T - the entity type
      Returns:
      the result of the query
      Throws:
      UnsupportedOperationException - If a NoSQL database does not support a specific operation or if the database does not support certain query conditions, an exception will be raised. For example, a wide-column may not support the OR operator, or a document database may not support the BETWEEN operator. The level of NoSQL database support for various conditions may vary depending on the database provider.
    • singleResult

      <T> Optional<T> singleResult()
      Executes the query and returns the result as a single element, wrapped in an Optional. If the query returns exactly one result, that result is returned in the Optional. If no result is found, Optional.empty() is returned. If more than one result is found, an exception specific to the Jakarta NoSQL provider may be thrown.

      Use this method when expecting a single result from a query. It provides a safe way to handle the case where zero or one result is expected, while also allowing for exceptional cases where multiple results are returned.

      Type Parameters:
      T - the type of the entity being queried
      Returns:
      an Optional containing the single result of the query, if present, or empty if no result is found
      Throws:
      UnsupportedOperationException - If a NoSQL database does not support a specific operation or if the database does not support certain query conditions, an exception will be raised. For example, a wide-column may not support the OR operator, or a document database may not support the BETWEEN operator. The level of NoSQL database support for various conditions may vary depending on the database provider.