org.apache.cayenne.query

## Class FluentSelect<T>

- java.lang.Object
- - org.apache.cayenne.query.IndirectQuery
  - - org.apache.cayenne.query.FluentSelect<T>

- All Implemented Interfaces:
    Serializable, Query, Select<T>
  Direct Known Subclasses:
    ColumnSelect, ObjectSelect

      public abstract class FluentSelect<T>
      extends IndirectQuery
      implements Select<T>

  Base class for `ObjectSelect` and `ColumnSelect`
  Since:
    4.0
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `cacheGroup`
    `protected QueryCacheStrategy` | `cacheStrategy`
    `protected String` | `dbEntityName`
    `protected String` | `entityName`
    `protected Class<?>` | `entityType`
    `protected int` | `limit`
    `protected int` | `offset`
    `protected Collection<Ordering>` | `orderings`
    `protected int` | `pageSize`
    `protected PrefetchTreeNode` | `prefetches`
    `protected int` | `statementFetchSize`
    `protected Expression` | `where`

    - ### Fields inherited from class org.apache.cayenne.query.IndirectQuery

      `dataMap, lastResolver, name, replacementQuery`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FluentSelect()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ResultBatchIterator<T>` | `batchIterator(ObjectContext context, int size)` Creates a ResultBatchIterator based on the provided context and batch size.
    `protected Query` | `createReplacementQuery(EntityResolver resolver)` Translates self to a SelectQuery.
    `String` | `getCacheGroup()`
    `QueryCacheStrategy` | `getCacheStrategy()`
    `String` | `getDbEntityName()`
    `String` | `getEntityName()`
    `Class<?>` | `getEntityType()`
    `int` | `getLimit()`
    `int` | `getOffset()`
    `Collection<Ordering>` | `getOrderings()`
    `int` | `getPageSize()`
    `PrefetchTreeNode` | `getPrefetches()`
    `int` | `getStatementFetchSize()`
    `Expression` | `getWhere()` Returns a WHERE clause Expression of this query.
    `void` | `iterate(ObjectContext context, ResultIteratorCallback<T> callback)` Creates a ResultIterator based on the provided context and passes it to a callback for processing.
    `ResultIterator<T>` | `iterator(ObjectContext context)` Creates a ResultIterator based on the provided context.
    `List<T>` | `select(ObjectContext context)` Selects objects using provided context.
    `T` | `selectOne(ObjectContext context)` Selects a single object using provided context.

    - ### Methods inherited from class org.apache.cayenne.query.IndirectQuery

      `createSQLAction, getDataMap, getMetaData, getName, getReplacementQuery, route, setDataMap, setName`

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

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

    - ### Methods inherited from interface org.apache.cayenne.query.Select

      `selectFirst`

    - ### Methods inherited from interface org.apache.cayenne.query.Query

      `createSQLAction, getDataMap, getMetaData, getName, route`

- - ### Field Detail

    - #### entityType

          protected Class<?> entityType

    - #### entityName

          protected String entityName

    - #### dbEntityName

          protected String dbEntityName

    - #### where

          protected Expression where

    - #### orderings

          protected Collection<Ordering> orderings

    - #### prefetches

          protected PrefetchTreeNode prefetches

    - #### limit

          protected int limit

    - #### offset

          protected int offset

    - #### pageSize

          protected int pageSize

    - #### statementFetchSize

          protected int statementFetchSize

    - #### cacheStrategy

          protected QueryCacheStrategy cacheStrategy

    - #### cacheGroup

          protected String cacheGroup

  - ### Constructor Detail

    - #### FluentSelect

          protected FluentSelect()

  - ### Method Detail

    - #### createReplacementQuery

          protected Query createReplacementQuery(EntityResolver resolver)

      Translates self to a SelectQuery.
      Specified by:
        `createReplacementQuery` in class `IndirectQuery`

    - #### getCacheGroup

          public String getCacheGroup()

    - #### getCacheStrategy

          public QueryCacheStrategy getCacheStrategy()

    - #### getStatementFetchSize

          public int getStatementFetchSize()

    - #### getPageSize

          public int getPageSize()

    - #### getLimit

          public int getLimit()

    - #### getOffset

          public int getOffset()

    - #### getEntityType

          public Class<?> getEntityType()

    - #### getEntityName

          public String getEntityName()

    - #### getDbEntityName

          public String getDbEntityName()

    - #### getWhere

          public Expression getWhere()

      Returns a WHERE clause Expression of this query.

    - #### getOrderings

          public Collection<Ordering> getOrderings()

    - #### getPrefetches

          public PrefetchTreeNode getPrefetches()

    - #### select

          public List<T> select(ObjectContext context)

      Description copied from interface: `Select`
      Selects objects using provided context.

      Essentially the inversion of "ObjectContext.select(Select)".

      Specified by:
        `select` in interface `Select<T>`

    - #### selectOne

          public T selectOne(ObjectContext context)

      Description copied from interface: `Select`
      Selects a single object using provided context. The query is expected to match zero or one object. It returns null if no objects were matched. If query matched more than one object, `CayenneRuntimeException` is thrown.

      Essentially the inversion of "ObjectContext.selectOne(Select)".

      Specified by:
        `selectOne` in interface `Select<T>`

    - #### iterate

          public void iterate(ObjectContext context,
                              ResultIteratorCallback<T> callback)

      Description copied from interface: `Select`
      Creates a ResultIterator based on the provided context and passes it to a callback for processing. The caller does not need to worry about closing the iterator. This method takes care of it.

      Essentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)".

      Specified by:
        `iterate` in interface `Select<T>`

    - #### iterator

          public ResultIterator<T> iterator(ObjectContext context)

      Description copied from interface: `Select`
      Creates a ResultIterator based on the provided context. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultIterator explicitly. Or use `Select.iterate(ObjectContext, ResultIteratorCallback)` as an alternative.

      Essentially the inversion of "ObjectContext.iterator(Select)".

      Specified by:
        `iterator` in interface `Select<T>`

    - #### batchIterator

          public ResultBatchIterator<T> batchIterator(ObjectContext context,
                                                      int size)

      Description copied from interface: `Select`
      Creates a ResultBatchIterator based on the provided context and batch size. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultBatchIterator explicitly.
      Specified by:
        `batchIterator` in interface `Select<T>`

Copyright © 2001–2023 Apache Cayenne. All rights reserved.