Package org.apache.cayenne.access.translator.select

## Class DefaultSelectTranslator

- java.lang.Object
- - org.apache.cayenne.access.translator.select.QueryAssembler
  - - org.apache.cayenne.access.translator.select.DefaultSelectTranslator

- All Implemented Interfaces:
    `SelectTranslator`
  Direct Known Subclasses:
    `IngresSelectTranslator`, `SQLServerSelectTranslator`, `SybaseSelectTranslator`

      public class DefaultSelectTranslator
      extends QueryAssembler
      implements SelectTranslator

  Since:
    4.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.cayenne.access.translator.select.QueryAssembler

      `QueryAssembler.AddBindingListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected static int[]` | `UNSUPPORTED_DISTINCT_TYPES` |

    - ### Fields inherited from class org.apache.cayenne.access.translator.select.QueryAssembler

      `adapter, addBindingListener, bindings, entityResolver, query, queryMetadata, sql, translated`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultSelectTranslator​(Query query, DbAdapter adapter, EntityResolver entityResolver)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `appendGroupByColumn​(StringBuilder buffer, Map.Entry<ColumnDescriptor,​List<DbAttributeBinding>> entry)` | Append single column to GROUP BY clause
    `protected void` | `appendGroupByColumns​(StringBuilder buffer, Map<ColumnDescriptor,​List<DbAttributeBinding>> groupByColumns)` | Append columns to GROUP BY clause
    `protected void` | `appendLimitAndOffsetClauses​(StringBuilder buffer)` | Handles appending optional limit and offset clauses.
    `protected void` | `appendSelectColumns​(StringBuilder buffer, List<String> selectColumnExpList)` |
    `protected String` | `buildDistinctStatement()` | Allows subclasses to insert their own dialect of DISTINCT statement to improve performance.
    `protected List<ColumnDescriptor>` | `buildResultColumns()` |
    `protected JoinStack` | `createJoinStack()` |
    `void` | `dbRelationshipAdded​(DbRelationship relationship, JoinType joinType, String joinSplitAlias)` | Appends a join with given semantics to the query.
    `protected void` | `doTranslate()` |
    `String` | `getAliasForExpression​(Expression exp)` |
    `Map<ObjAttribute,​ColumnDescriptor>` | `getAttributeOverrides()` | Returns a map of ColumnDescriptors keyed by ObjAttribute for columns that may need to be reprocessed manually due to incompatible mappings along the inheritance hierarchy.
    `String` | `getCurrentAlias()` | Returns an alias of the table which is currently at the top of the join stack.
    `protected JoinStack` | `getJoinStack()` |
    `ColumnDescriptor[]` | `getResultColumns()` | Returns a list of ColumnDescriptors for the query columns.
    `boolean` | `hasJoins()` |
    `boolean` | `isSuppressingDistinct()` | Returns true if SelectTranslator determined that a query requiring DISTINCT can't be run with DISTINCT keyword for internal reasons.
    `protected static boolean` | `isUnsupportedForDistinct​(int type)` |
    `void` | `resetJoinStack()` | A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.
    `boolean` | `supportsTableAliases()` | Always returns true.

    - ### Methods inherited from class org.apache.cayenne.access.translator.select.QueryAssembler

      `addToParamList, ensureTranslated, getAdapter, getBindings, getEntityResolver, getPathAliases, getQuery, getQueryMetadata, getSql, setAddBindingListener`

    - ### 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.access.translator.select.SelectTranslator

      `getBindings, getSql`

- - ### Field Detail

    - #### UNSUPPORTED_DISTINCT_TYPES

          protected static final int[] UNSUPPORTED_DISTINCT_TYPES

  - ### Constructor Detail

    - #### DefaultSelectTranslator

          public DefaultSelectTranslator​(Query query,
                                         DbAdapter adapter,
                                         EntityResolver entityResolver)

  - ### Method Detail

    - #### isUnsupportedForDistinct

          protected static boolean isUnsupportedForDistinct​(int type)

    - #### getJoinStack

          protected JoinStack getJoinStack()

    - #### createJoinStack

          protected JoinStack createJoinStack()

    - #### doTranslate

          protected void doTranslate()

      Specified by:
        `doTranslate` in class `QueryAssembler`

    - #### buildDistinctStatement

          protected String buildDistinctStatement()

      Allows subclasses to insert their own dialect of DISTINCT statement to improve performance.
      Returns:
        string representing the DISTINCT statement
      Since:
        4.0

    - #### appendSelectColumns

          protected void appendSelectColumns​(StringBuilder buffer,
                                             List<String> selectColumnExpList)

      Since:
        3.1

    - #### appendGroupByColumns

          protected void appendGroupByColumns​(StringBuilder buffer,
                                              Map<ColumnDescriptor,​List<DbAttributeBinding>> groupByColumns)

      Append columns to GROUP BY clause
      Since:
        4.0

    - #### appendGroupByColumn

          protected void appendGroupByColumn​(StringBuilder buffer,
                                             Map.Entry<ColumnDescriptor,​List<DbAttributeBinding>> entry)

      Append single column to GROUP BY clause
      Since:
        4.0

    - #### appendLimitAndOffsetClauses

          protected void appendLimitAndOffsetClauses​(StringBuilder buffer)

      Handles appending optional limit and offset clauses. This implementation does nothing, deferring to subclasses to define the LIMIT/OFFSET clause syntax.
      Since:
        3.0

    - #### getCurrentAlias

          public String getCurrentAlias()

      Description copied from class: `QueryAssembler`
      Returns an alias of the table which is currently at the top of the join stack.
      Specified by:
        `getCurrentAlias` in class `QueryAssembler`

    - #### getResultColumns

          public ColumnDescriptor[] getResultColumns()

      Returns a list of ColumnDescriptors for the query columns.
      Specified by:
        `getResultColumns` in interface `SelectTranslator`
      Since:
        1.2

    - #### getAttributeOverrides

          public Map<ObjAttribute,​ColumnDescriptor> getAttributeOverrides()

      Returns a map of ColumnDescriptors keyed by ObjAttribute for columns that may need to be reprocessed manually due to incompatible mappings along the inheritance hierarchy.
      Specified by:
        `getAttributeOverrides` in interface `SelectTranslator`
      Since:
        1.2

    - #### isSuppressingDistinct

          public boolean isSuppressingDistinct()

      Returns true if SelectTranslator determined that a query requiring DISTINCT can't be run with DISTINCT keyword for internal reasons. If this method returns true, DataNode may need to do in-memory distinct filtering.
      Specified by:
        `isSuppressingDistinct` in interface `SelectTranslator`
      Since:
        1.1

    - #### buildResultColumns

          protected List<ColumnDescriptor> buildResultColumns()

    - #### resetJoinStack

          public void resetJoinStack()

      Description copied from class: `QueryAssembler`
      A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.
      Specified by:
        `resetJoinStack` in class `QueryAssembler`
      Since:
        3.0

    - #### dbRelationshipAdded

          public void dbRelationshipAdded​(DbRelationship relationship,
                                          JoinType joinType,
                                          String joinSplitAlias)

      Description copied from class: `QueryAssembler`
      Appends a join with given semantics to the query.
      Specified by:
        `dbRelationshipAdded` in class `QueryAssembler`
      Since:
        3.0

    - #### supportsTableAliases

          public boolean supportsTableAliases()

      Always returns true.
      Overrides:
        `supportsTableAliases` in class `QueryAssembler`

    - #### getAliasForExpression

          public String getAliasForExpression​(Expression exp)

      Specified by:
        `getAliasForExpression` in class `QueryAssembler`

    - #### hasJoins

          public boolean hasJoins()

      Specified by:
        `hasJoins` in interface `SelectTranslator`
      Returns:
        do query has at least one join
      Since:
        4.0