org.apache.cayenne.access.trans
Class QueryAssembler

java.lang.Object
  extended by org.apache.cayenne.access.QueryTranslator
      extended by org.apache.cayenne.access.trans.QueryAssembler
Direct Known Subclasses:
DeleteTranslator, InsertTranslator, SelectTranslator, UpdateTranslator

public abstract class QueryAssembler
extends QueryTranslator

Abstract superclass of Query translators.

Author:
Andrei Adamchik

Field Summary
protected  java.util.List attributes
          PreparedStatement attributes matching entries in values list.
protected  java.util.List values
          PreparedStatement values.
 
Fields inherited from class org.apache.cayenne.access.QueryTranslator
adapter, connection, engine, entityResolver, query
 
Constructor Summary
QueryAssembler()
           
 
Method Summary
 void addToParamList(DbAttribute dbAttr, java.lang.Object anObject)
          Registers anObject as a PreparedStatement paramter.
abstract  java.lang.String aliasForTable(DbEntity dbEnt)
          Returns a name that can be used as column alias.
 java.lang.String aliasForTable(DbEntity ent, DbRelationship rel)
           
abstract  java.lang.String createSqlString()
          Translates query into sql string.
 java.sql.PreparedStatement createStatement()
          Translates internal query into PreparedStatement.
abstract  void dbRelationshipAdded(DbRelationship dbRel)
          Processes a join being added.
protected  void initStatement(java.sql.PreparedStatement stmt)
          Initializes prepared statements with collected parameters.
 boolean supportsTableAliases()
          Returns true if table aliases are supported.
 
Methods inherited from class org.apache.cayenne.access.QueryTranslator
createStatement, getAdapter, getCon, getConnection, getEngine, getEntityResolver, getQuery, getRootDbEntity, getRootEntity, getRootInheritanceTree, setAdapter, setCon, setConnection, setEngine, setEntityResolver, setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected java.util.List values
PreparedStatement values.


attributes

protected java.util.List attributes
PreparedStatement attributes matching entries in values list.

Constructor Detail

QueryAssembler

public QueryAssembler()
Method Detail

dbRelationshipAdded

public abstract void dbRelationshipAdded(DbRelationship dbRel)
Processes a join being added.


createSqlString

public abstract java.lang.String createSqlString()
                                          throws java.lang.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:
java.lang.Exception

aliasForTable

public java.lang.String aliasForTable(DbEntity ent,
                                      DbRelationship rel)

aliasForTable

public abstract java.lang.String aliasForTable(DbEntity dbEnt)
Returns a name that can be used as column alias. This can be one of the following: CayenneRuntimeException is thrown if a table alias can not be created.


supportsTableAliases

public boolean supportsTableAliases()
Returns true if table aliases are supported. Default implementation returns false.


addToParamList

public void addToParamList(DbAttribute dbAttr,
                           java.lang.Object anObject)
Registers anObject as a PreparedStatement paramter.

Parameters:
anObject - object that represents a value of DbAttribute
dbAttr - DbAttribute being processed.

createStatement

public java.sql.PreparedStatement createStatement()
                                           throws java.lang.Exception
Translates internal query into PreparedStatement.

Specified by:
createStatement in class QueryTranslator
Throws:
java.lang.Exception

initStatement

protected void initStatement(java.sql.PreparedStatement stmt)
                      throws java.lang.Exception
Initializes prepared statements with collected parameters. Called internally from "createStatement". Cayenne users shouldn't normally call it directly.

Throws:
java.lang.Exception


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