org.apache.cayenne.access.trans

## Class QueryAssembler

- java.lang.Object
- - org.apache.cayenne.access.trans.QueryAssembler

- Direct Known Subclasses:
    SelectTranslator

      public abstract class QueryAssembler
      extends Object

  Abstract superclass of Query translators.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DbAdapter` | `adapter`
    `protected List<DbAttribute>` | `attributes` PreparedStatement attributes matching entries in `values` list.
    `protected Connection` | `connection`
    `protected EntityResolver` | `entityResolver`
    `protected JdbcEventLogger` | `logger`
    `protected int` | `parameterIndex` The index parameter will be inserted at in parameter list
    `protected Query` | `query`
    `protected QueryMetadata` | `queryMetadata`
    `protected List<Object>` | `values` Holds PreparedStatement values.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryAssembler()`

  - ### 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 String` | `createSqlString()` Translates query into sql string.
    `PreparedStatement` | `createStatement()` Translates internal query into PreparedStatement.
    `abstract void` | `dbRelationshipAdded(DbRelationship relationship, JoinType joinType, String joinSplitAlias)` Appends a join with given semantics to the query.
    `DbAdapter` | `getAdapter()`
    `abstract String` | `getCurrentAlias()` Returns an alias of the table which is currently at the top of the join stack.
    `EntityResolver` | `getEntityResolver()`
    `JdbcEventLogger` | `getJdbcEventLogger()`
    `protected Map<String,String>` | `getPathAliases()` Returns aliases for the path splits defined in the query.
    `Query` | `getQuery()` Returns query object being processed.
    `QueryMetadata` | `getQueryMetadata()`
    `DbEntity` | `getRootDbEntity()`
    `ObjEntity` | `getRootEntity()`
    `protected void` | `initStatement(PreparedStatement stmt)` Initializes prepared statements with collected parameters.
    `abstract void` | `resetJoinStack()` A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.
    `void` | `setAdapter(DbAdapter adapter)`
    `void` | `setConnection(Connection connection)`
    `void` | `setEntityResolver(EntityResolver entityResolver)`
    `void` | `setJdbcEventLogger(JdbcEventLogger logger)`
    `void` | `setQuery(Query query)`
    `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

    - #### connection

          protected Connection connection

    - #### adapter

          protected DbAdapter adapter

    - #### entityResolver

          protected EntityResolver entityResolver

    - #### logger

          protected JdbcEventLogger logger

    - #### values

          protected List<Object> values

      Holds PreparedStatement values.

    - #### attributes

          protected List<DbAttribute> attributes

      PreparedStatement attributes matching entries in `values` list.

    - #### parameterIndex

          protected int parameterIndex

      The index parameter will be inserted at in parameter list

  - ### Constructor Detail

    - #### QueryAssembler

          public QueryAssembler()

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

    - #### setQuery

          public void setQuery(Query query)

    - #### setConnection

          public void setConnection(Connection connection)

    - #### setAdapter

          public void setAdapter(DbAdapter adapter)

    - #### setJdbcEventLogger

          public void setJdbcEventLogger(JdbcEventLogger logger)

      Since:
        3.1

    - #### getJdbcEventLogger

          public JdbcEventLogger getJdbcEventLogger()

      Since:
        3.1

    - #### setEntityResolver

          public void setEntityResolver(EntityResolver entityResolver)

    - #### getRootDbEntity

          public DbEntity getRootDbEntity()

    - #### getRootEntity

          public ObjEntity getRootEntity()

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

    - #### createSqlString

          public abstract String createSqlString()
                                          throws Exception

      Translates query into sql string. This is a workhorse method of QueryAssembler. It is called internally from `createStatement`. Usually there is no need to invoke it explicitly.
      Throws:
        `Exception`

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

    - #### createStatement

          public PreparedStatement createStatement()
                                            throws Exception

      Translates internal query into PreparedStatement.
      Throws:
        `Exception`

    - #### initStatement

          protected void initStatement(PreparedStatement stmt)
                                throws Exception

      Initializes prepared statements with collected parameters. Called internally from "createStatement". Cayenne users shouldn't normally call it directly.
      Throws:
        `Exception`

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