com.holonplatform.core.datastore.beans

## Interface BeanQuery<T>

- Type Parameters:
    `T` - Bean type
  All Superinterfaces:
    BeanQueryBuilder<BeanQuery<T>>, ExpressionResolver.ExpressionResolverBuilder<BeanQuery<T>>, QueryAggregation.QueryAggregationSupport<BeanQuery<T>>, QueryFilter.QueryFilterSupport<BeanQuery<T>>, QuerySort.QuerySortSupport<BeanQuery<T>>

      public interface BeanQuery<T>
      extends BeanQueryBuilder<BeanQuery<T>>

  A query which uses a bean class for query composition and projections.
  Since:
    5.1.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `count()` Count all the results of a query.
    `default Optional<T>` | `findOne()` Execute query and get an expected unique result bean.
    `default List<T>` | `list()` Convenience method to obtain the query results `stream()` as a `List`.
    `Stream<T>` | `stream()` Execute query and get a `Stream` of bean query results.

    - ### Methods inherited from interface com.holonplatform.core.datastore.beans.BeanQueryBuilder

      `getQueryConfiguration, limit, offset, parameter, parameter, restrict`

    - ### Methods inherited from interface com.holonplatform.core.query.QueryFilter.QueryFilterSupport

      `filter, filter, filter`

    - ### Methods inherited from interface com.holonplatform.core.query.QuerySort.QuerySortSupport

      `sort, sort, sort`

    - ### Methods inherited from interface com.holonplatform.core.query.QueryAggregation.QueryAggregationSupport

      `aggregate, aggregate, aggregate`

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolver.ExpressionResolverBuilder

      `withExpressionResolver`

- - ### Method Detail

    - #### stream

          Stream<T> stream()

      Execute query and get a `Stream` of bean query results.
      Returns:
        Query results stream
      Throws:
        `DataAccessException` - Error in query execution

    - #### list

          default List<T> list()

      Convenience method to obtain the query results `stream()` as a `List`.
      Returns:
        Query results list
      Throws:
        `DataAccessException` - Error in query execution

    - #### findOne

          default Optional<T> findOne()
                               throws QueryResults.QueryNonUniqueResultException

      Execute query and get an expected unique result bean.

      If more than one result is returned by the query, a `QueryResults.QueryNonUniqueResultException` is thrown.

      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found
        `DataAccessException` - Error in query execution

    - #### count

          long count()

      Count all the results of a query.
      Returns:
        Total results count
      Throws:
        `DataAccessException` - Error in query execution

Copyright © 2019 The Holon Platform. All rights reserved.