Class Query

java.lang.Object
org.springframework.data.relational.core.query.Query

public class Query extends Object
Query object representing Criteria, columns, Sort, and limit/offset for a SQL query. Methods on this class are designed to be used in a fluent style creating immutable objects.
Since:
2.0
Author:
Mark Paluch
See Also:
  • Method Details

    • query

      public static Query query(CriteriaDefinition criteria)
      Static factory method to create a Query using the provided CriteriaDefinition.
      Parameters:
      criteria - must not be null.
      Returns:
      a new Query for the given Criteria.
    • empty

      public static Query empty()
      Create a new empty Query.
      Returns:
    • columns

      @CheckReturnValue public Query columns(String... columns)
      Add columns to the query.
      Parameters:
      columns -
      Returns:
      a new Query object containing the former settings with columns applied.
    • columns

      @CheckReturnValue public Query columns(Collection<String> columns)
      Add columns to the query.
      Parameters:
      columns -
      Returns:
      a new Query object containing the former settings with columns applied.
    • columns

      @CheckReturnValue public Query columns(SqlIdentifier... columns)
      Add columns to the query.
      Parameters:
      columns -
      Returns:
      a new Query object containing the former settings with columns applied.
      Since:
      1.1
    • offset

      @CheckReturnValue public Query offset(long offset)
      Set number of rows to skip before returning results.
      Parameters:
      offset -
      Returns:
      a new Query object containing the former settings with offset applied.
    • limit

      @CheckReturnValue public Query limit(int limit)
      Limit the number of returned documents to limit.
      Parameters:
      limit -
      Returns:
      a new Query object containing the former settings with limit applied.
    • with

      @CheckReturnValue public Query with(Pageable pageable)
      Set the given pagination information on the Query instance. Will transparently set offset and limit as well as applying the Sort instance defined with the Pageable.
      Parameters:
      pageable -
      Returns:
      a new Query object containing the former settings with Pageable applied.
    • sort

      @CheckReturnValue public Query sort(Sort sort)
      Add a Sort to the Query instance.
      Parameters:
      sort -
      Returns:
      a new Query object containing the former settings with Sort applied.
    • getCriteria

      public Optional<CriteriaDefinition> getCriteria()
      Return the Criteria to be applied.
      Returns:
    • getColumns

      public List<SqlIdentifier> getColumns()
      Return the columns that this query should project.
      Returns:
    • isSorted

      public boolean isSorted()
      Return true if the Query has a sort parameter.
      Returns:
      true if sorted.
      See Also:
    • getSort

      public Sort getSort()
    • getOffset

      public long getOffset()
      Return the number of rows to skip.
      Returns:
    • getLimit

      public int getLimit()
      Return the maximum number of rows to be return.
      Returns:
    • isLimited

      public boolean isLimited()
      Return whether the query has a limit.
      Returns:
      true if a limit is set.
      Since:
      3.0
      See Also: