org.apache.cayenne.access.translator.select

## Class QueryAssembler

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

- Direct Known Subclasses:
    DefaultSelectTranslator

      public abstract class QueryAssembler
      extends Object

  Abstract superclass of Query translators.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static interface` | `QueryAssembler.AddBindingListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DbAdapter` | `adapter`
    `protected QueryAssembler.AddBindingListener` | `addBindingListener`
    `protected List<DbAttributeBinding>` | `bindings`
    `protected EntityResolver` | `entityResolver`
    `protected Query` | `query`
    `protected QueryMetadata` | `queryMetadata`
    `protected String` | `sql`
    `protected boolean` | `translated`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryAssembler(Query query, DbAdapter adapter, EntityResolver entityResolver)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addToParamList(DbAttribute dbAttr, Object anObject)` Registers `anObject` as a PreparedStatement parameter.
    `abstract void` | `dbRelationshipAdded(DbRelationship relationship, JoinType joinType, String joinSplitAlias)` Appends a join with given semantics to the query.
    `protected abstract void` | `doTranslate()`
    `protected void` | `ensureTranslated()`
    `DbAdapter` | `getAdapter()`
    `abstract String` | `getAliasForExpression(Expression exp)`
    `DbAttributeBinding[]` | `getBindings()`
    `abstract String` | `getCurrentAlias()` Returns an alias of the table which is currently at the top of the join stack.
    `EntityResolver` | `getEntityResolver()`
    `protected Map<String,String>` | `getPathAliases()` Returns aliases for the path splits defined in the query.
    `Query` | `getQuery()` Returns query object being processed.
    `QueryMetadata` | `getQueryMetadata()`
    `String` | `getSql()` Translates query into an SQL string formatted to use in a PreparedStatement.
    `abstract void` | `resetJoinStack()` A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.
    `void` | `setAddBindingListener(QueryAssembler.AddBindingListener addBindingListener)`
    `boolean` | `supportsTableAliases()` Returns `true` if table aliases are supported.

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

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

- - ### Field Detail

    - #### query

          protected Query query

    - #### queryMetadata

          protected QueryMetadata queryMetadata

    - #### translated

          protected boolean translated

    - #### sql

          protected String sql

    - #### adapter

          protected DbAdapter adapter

    - #### entityResolver

          protected EntityResolver entityResolver

    - #### bindings

          protected List<DbAttributeBinding> bindings

    - #### addBindingListener

          protected QueryAssembler.AddBindingListener addBindingListener

      Since:
        4.0

  - ### Constructor Detail

    - #### QueryAssembler

          public QueryAssembler(Query query,
                                DbAdapter adapter,
                                EntityResolver entityResolver)

      Since:
        4.0

  - ### Method Detail

    - #### getPathAliases

          protected Map<String,String> getPathAliases()

      Returns aliases for the path splits defined in the query.
      Since:
        3.0

    - #### getEntityResolver

          public EntityResolver getEntityResolver()

    - #### getAdapter

          public DbAdapter getAdapter()

    - #### getQuery

          public Query getQuery()

      Returns query object being processed.

    - #### getQueryMetadata

          public QueryMetadata getQueryMetadata()

    - #### resetJoinStack

          public abstract void resetJoinStack()

      A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.
      Since:
        3.0

    - #### getCurrentAlias

          public abstract String getCurrentAlias()

      Returns an alias of the table which is currently at the top of the join stack.
      Since:
        3.0

    - #### dbRelationshipAdded

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

      Appends a join with given semantics to the query.
      Since:
        3.0

    - #### getSql

          public String getSql()

      Translates query into an SQL string formatted to use in a PreparedStatement.

    - #### ensureTranslated

          protected void ensureTranslated()

      Since:
        4.0

    - #### doTranslate

          protected abstract void doTranslate()

      Since:
        4.0

    - #### supportsTableAliases

          public boolean supportsTableAliases()

      Returns `true` if table aliases are supported. Default implementation returns false.

    - #### addToParamList

          public void addToParamList(DbAttribute dbAttr,
                                     Object anObject)

      Registers `anObject` as a PreparedStatement parameter.
      Parameters:
        `anObject` - object that represents a value of DbAttribute
        `dbAttr` - DbAttribute being processed.

    - #### getBindings

          public DbAttributeBinding[] getBindings()

      Since:
        4.0

    - #### getAliasForExpression

          public abstract String getAliasForExpression(Expression exp)

      Since:
        4.0

    - #### setAddBindingListener

          public void setAddBindingListener(QueryAssembler.AddBindingListener addBindingListener)

      Since:
        4.0

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