Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.access.trans
Class QueryAssemblerHelper

    java.lang.Object
      org.apache.cayenne.access.trans.QueryAssemblerHelper

Direct Known Subclasses:
  OrderingTranslator, QualifierTranslator

    public abstract class QueryAssemblerHelper

extends java.lang.Object

Translates parts of the query to SQL. Always works in the context of parent Translator.

Author:
  Andrei Adamchik

Field Summary
`protected QueryAssembler` | `queryAssembler`

Constructor Summary
`QueryAssemblerHelper()`
`QueryAssemblerHelper(QueryAssembler queryAssembler)` Creates QueryAssemblerHelper.

Method Summary
`protected void` | `appendDbPath(java.lang.StringBuffer buf, Expression pathExp)`
`protected void` | `appendLiteral(java.lang.StringBuffer buf, java.lang.Object val, DbAttribute attr, Expression parentExpression)` Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built.
`protected void` | `appendLiteralDirect(java.lang.StringBuffer buf, java.lang.Object val, DbAttribute attr, Expression parentExpression)` Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built.
`protected void` | `appendObjPath(java.lang.StringBuffer buf, Expression pathExp)` Processes parts of the OBJ_PATH expression.
`abstract java.lang.String` | `doTranslation()` Translates the part of parent translator's query that is supported by this PartTranslator.
`DbEntity` | `getDbEntity()`
`ObjEntity` | `getObjEntity()`
`QueryAssembler` | `getQueryAssembler()` Returns parent QueryAssembler that uses this helper.
`protected DbAttribute` | `paramsDbType(Expression e)` Returns database type of expression parameters or null if it can not be determined.
`protected void` | `processColumn(java.lang.StringBuffer buf, DbAttribute dbAttr)`
`protected void` | `processColumn(java.lang.StringBuffer buf, DbAttribute dbAttr, DbRelationship relationship)`
`protected void` | `processColumn(java.lang.StringBuffer buf, Expression nameExp)` Appends column name of a column in a root entity.
`protected void` | `processRelTermination(java.lang.StringBuffer buf, DbRelationship rel)` Handles case when a DB_NAME expression ends with relationship.
`protected void` | `processRelTermination(java.lang.StringBuffer buf, ObjRelationship rel)` Processes case when an OBJ_PATH expression ends with relationship.
`void` | `setQueryAssembler(QueryAssembler queryAssembler)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### queryAssembler

    protected QueryAssembler queryAssembler

Constructor Detail

### QueryAssemblerHelper

    public QueryAssemblerHelper()

### QueryAssemblerHelper

    public QueryAssemblerHelper(QueryAssembler queryAssembler)

  Creates QueryAssemblerHelper. Sets queryAssembler property.

Method Detail

### getQueryAssembler

    public QueryAssembler getQueryAssembler()

  Returns parent QueryAssembler that uses this helper.

### setQueryAssembler

    public void setQueryAssembler(QueryAssembler queryAssembler)

### doTranslation

    public abstract java.lang.String doTranslation()

  Translates the part of parent translator's query that is supported by this PartTranslator. For example, QualifierTranslator will process qualifier expression, OrderingTranslator - ordering of the query. In the process of translation parent translator is notified of any join tables added (so that it can update its "FROM" clause). Also parent translator is consulted about table aliases to use when translating columns.

### getObjEntity

    public ObjEntity getObjEntity()

### getDbEntity

    public DbEntity getDbEntity()

### appendObjPath

    protected void appendObjPath(java.lang.StringBuffer buf,
                                 Expression pathExp)

  Processes parts of the OBJ_PATH expression.

### appendDbPath

    protected void appendDbPath(java.lang.StringBuffer buf,
                                Expression pathExp)

### processColumn

    protected void processColumn(java.lang.StringBuffer buf,
                                 Expression nameExp)

  Appends column name of a column in a root entity.

### processColumn

    protected void processColumn(java.lang.StringBuffer buf,
                                 DbAttribute dbAttr,
                                 DbRelationship relationship)

### processColumn

    protected void processColumn(java.lang.StringBuffer buf,
                                 DbAttribute dbAttr)

### appendLiteral

    protected void appendLiteral(java.lang.StringBuffer buf,
                                 java.lang.Object val,
                                 DbAttribute attr,
                                 Expression parentExpression)

  Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built. Adds `val` into QueryAssembler parameter list.

  If `val` is null, "NULL" is appended to the query.

  If `val` is a DataObject, its primary key value is used as a parameter. Only objects with a single column primary key can be used.

  Parameters:
    `buf` - query buffer.
    `val` - object that should be appended as a literal to the query. Must be of one of "standard JDBC" types, null or a DataObject.
    `attr` - DbAttribute that has information on what type of parameter is being appended.

### appendLiteralDirect

    protected void appendLiteralDirect(java.lang.StringBuffer buf,
                                       java.lang.Object val,
                                       DbAttribute attr,
                                       Expression parentExpression)

  Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built. Adds `val` into QueryAssembler parameter list.

  Parameters:
    `buf` - query buffer
    `val` - object that should be appended as a literal to the query. Must be of one of "standard JDBC" types. Can not be null.

### paramsDbType

    protected DbAttribute paramsDbType(Expression e)

  Returns database type of expression parameters or null if it can not be determined.

### processRelTermination

    protected void processRelTermination(java.lang.StringBuffer buf,
                                         ObjRelationship rel)

  Processes case when an OBJ_PATH expression ends with relationship. If this is a "to many" relationship, a join is added and a column expression for the target entity primary key. If this is a "to one" relationship, column expresion for the source foreign key is added.

### processRelTermination

    protected void processRelTermination(java.lang.StringBuffer buf,
                                         DbRelationship rel)

  Handles case when a DB_NAME expression ends with relationship. If this is a "to many" relationship, a join is added and a column expression for the target entity primary key. If this is a "to one" relationship, column expresion for the source foreign key is added.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.