org.springframework.data.relational.core.query

## 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. `Query` is created with a fluent API creating immutable objects.

Since:
  2.0
Author:
  Mark Paluch
See Also:
  `Criteria`, `Sort`, `Pageable`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Query` `columns(Collection<String> columns)` Add columns to the query.
`Query` `columns(SqlIdentifier... columns)` Add columns to the query.
`Query` `columns(String... columns)` Add columns to the query.
`static Query` `empty()` Create a new empty `Query`.
`List<SqlIdentifier>` `getColumns()` Return the columns that this query should project.
`Optional<CriteriaDefinition>` `getCriteria()` Return the `Criteria` to be applied.
`int` `getLimit()` Return the maximum number of rows to be return.
`long` `getOffset()` Return the number of rows to skip.
`Sort` `getSort()`
`boolean` `isSorted()` Return true if the `Query` has a sort parameter.
`Query` `limit(int limit)` Limit the number of returned documents to `limit`.
`Query` `offset(long offset)` Set number of rows to skip before returning results.
`static Query` `query(CriteriaDefinition criteria)` Static factory method to create a `Query` using the provided `CriteriaDefinition`.
`Query` `sort(Sort sort)` Add a `Sort` to the `Query` instance.
`Query` `with(Pageable pageable)` Set the given pagination information on the `Query` instance.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### 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

    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

    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

    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

    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

    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

    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

    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:
  `Sort.isSorted()`

#### 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: